r67179 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r67178‎ | r67179 | r67180 >
Date:08:58, 1 June 2010
Author:tstarling
Status:ok
Tags:
Comment:
* Per Aryeh's suggestion on CR r66987, treat categories larger than a certain size as empty. The visual presentation is not perfect, but it needs some more aggressive treatment than what I can give it right now.
* Get counts into local variables, to make the code slightly more compact.
Modified paths:
  • /trunk/extensions/CategoryTree/CategoryTree.php (modified) (history)
  • /trunk/extensions/CategoryTree/CategoryTreeFunctions.php (modified) (history)

Diff [purge]

Index: trunk/extensions/CategoryTree/CategoryTree.php
@@ -36,6 +36,7 @@
3737 * Options:
3838 *
3939 * $wgCategoryTreeMaxChildren - maximum number of children shown in a tree node. Default is 200
 40+ * $wgCategoryTreeMaxScanRows - maximum number of rows the DBMS may scan while showing a tree node.
4041 * $wgCategoryTreeAllowTag - enable <categorytree> tag. Default is true.
4142 * $wgCategoryTreeDynamicTag - loads the first level of the tree in a <categorytag> dynamically.
4243 * This way, the cache does not need to be disabled. Default is false.
@@ -51,6 +52,7 @@
5253 */
5354
5455 $wgCategoryTreeMaxChildren = 200;
 56+$wgCategoryTreeMaxScanRows = 10000;
5557 $wgCategoryTreeAllowTag = true;
5658 $wgCategoryTreeDisableCache = true;
5759 $wgCategoryTreeDynamicTag = false;
Index: trunk/extensions/CategoryTree/CategoryTreeFunctions.php
@@ -603,6 +603,7 @@
604604 * $info must be an associative array, containing at least a Title object under the 'title' key.
605605 */
606606 function renderNodeInfo( $title, $cat, $children = 0, $loadchildren = false ) {
 607+ global $wgCategoryTreeMaxScanRows;
607608 static $uniq = 0;
608609
609610 $mode = $this->getOption( 'mode' );
@@ -675,19 +676,23 @@
676677
677678 $attr = array( 'class' => 'CategoryTreeBullet' );
678679
 680+ # Get counts, with conversion to integer so === works
 681+ $pageCount = intval( $cat->getPageCount() );
 682+ $subcatCount = intval( $cat->getSubcatCount() );
 683+ $fileCount = intval( $cat->getFileCount() );
 684+
679685 if ( $ns == NS_CATEGORY ) {
 686+
680687 if ( $cat ) {
681688 if ( $mode == CT_MODE_CATEGORIES ) {
682 - $count = $cat->getSubcatCount();
 689+ $count = $subcatCount;
683690 } else if ( $mode == CT_MODE_PAGES ) {
684 - $count = $cat->getPageCount() - $cat->getFileCount();
 691+ $count = $pageCount - $fileCount;
685692 } else {
686 - $count = $cat->getPageCount();
 693+ $count = $pageCount;
687694 }
688 - # Fix conversion to string for ===
689 - $count = intval( $count );
690695 }
691 - if ( $count === 0 ) {
 696+ if ( $count === 0 || $pageCount > $wgCategoryTreeMaxScanRows ) {
692697 $bullet = wfMsgNoTrans( 'categorytree-empty-bullet' ) . ' ';
693698 $attr['class'] = 'CategoryTreeEmptyBullet';
694699 } else {
@@ -721,15 +726,15 @@
722727 } else {
723728 $bullet = wfMsgNoTrans( 'categorytree-page-bullet' );
724729 }
725 - $s .= Xml::tags( 'span', $attr, $bullet );
 730+ $s .= Xml::tags( 'span', $attr, $bullet ) . ' ';
726731
727732 $s .= Xml::openElement( 'a', array( 'class' => $labelClass, 'href' => $wikiLink ) ) . $label . Xml::closeElement( 'a' );
728733
729734 if ( $count !== false && $this->getOption( 'showcount' ) ) {
730 - $pages = $cat->getPageCount() - $cat->getSubcatCount() - $cat->getFileCount();
 735+ $pages = $pageCount - $subcatCount - $fileCount;
731736
732737 $attr = array(
733 - 'title' => wfMsgExt( 'categorytree-member-counts', 'parsemag', $cat->getSubcatCount(), $pages , $cat->getFileCount(), $cat->getPageCount(), $count )
 738+ 'title' => wfMsgExt( 'categorytree-member-counts', 'parsemag', $subcatCount, $pages , $fileCount, $pageCount, $count )
734739 );
735740
736741 $s .= ' ';
@@ -737,10 +742,10 @@
738743 $s .= Xml::tags( 'span', $attr,
739744 wfMsgExt( 'categorytree-member-num',
740745 array( 'parsemag', 'escapenoentities' ),
741 - $cat->getSubcatCount(),
 746+ $subcatCount,
742747 $pages,
743 - $cat->getFileCount(),
744 - $cat->getPageCount(),
 748+ $fileCount,
 749+ $pageCount,
745750 $wgLang->formatNum( $count ) ) );
746751 }
747752

Follow-up revisions

RevisionCommit summaryAuthorDate
r67181Merged all changes from r62820 to r67179 from trunk, to get r66987 and r67179...tstarling11:58, 1 June 2010
r71174Adapt CategoryTree to the new schema...simetrical21:57, 16 August 2010

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r66987* (bug 23682) Don't allow people to expand subtree when it's known to be empt...tstarling02:15, 28 May 2010

Status & tagging log