r71174 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r71173‎ | r71174 | r71175 >
Date:21:57, 16 August 2010
Author:simetrical
Status:ok
Tags:
Comment:
Adapt CategoryTree to the new schema

This should obsolete $wgCategoryTreeMaxScanRows, added in r67179, so I
removed it. Note that I only tested with very basic usage, since I
don't quite understand all the complicated things this extension can do,
and some code paths are certainly going to remain inefficient, since
arbitrary namespace filtering seems possible here (at least
renderChildren() has support for it). However, clicking the little plus
sign on category pages should now scan only as many rows as are actually
used, so no limit should be necessary.

Sorting is now by cl_type, cl_sortkey instead of cl_sortkey. This
change has to be made to all users for efficiency, since the old index
was dropped. It means the sort order might be somewhat unexpected in
some cases, but for basic CategoryTree use it makes no difference, since
all the results have cl_type = 'subcat' anyway.

Fixes bug 23682, I think.
Modified paths:
  • /trunk/extensions/CategoryTree/CategoryTree.php (modified) (history)
  • /trunk/extensions/CategoryTree/CategoryTreeFunctions.php (modified) (history)

Diff [purge]

Index: trunk/extensions/CategoryTree/CategoryTree.php
@@ -37,7 +37,6 @@
3838 * Options:
3939 *
4040 * $wgCategoryTreeMaxChildren - maximum number of children shown in a tree node. Default is 200
41 - * $wgCategoryTreeMaxScanRows - maximum number of rows the DBMS may scan while showing a tree node.
4241 * $wgCategoryTreeAllowTag - enable <categorytree> tag. Default is true.
4342 * $wgCategoryTreeDynamicTag - loads the first level of the tree in a <categorytag> dynamically.
4443 * This way, the cache does not need to be disabled. Default is false.
@@ -53,7 +52,6 @@
5453 */
5554
5655 $wgCategoryTreeMaxChildren = 200;
57 -$wgCategoryTreeMaxScanRows = 10000;
5856 $wgCategoryTreeAllowTag = true;
5957 $wgCategoryTreeDisableCache = true;
6058 $wgCategoryTreeDynamicTag = false;
Index: trunk/extensions/CategoryTree/CategoryTreeFunctions.php
@@ -444,9 +444,9 @@
445445 $where['page_namespace'] = $namespaces;
446446 } elseif ( $mode != CT_MODE_ALL ) {
447447 if ( $mode == CT_MODE_PAGES ) {
448 - $where = array_merge( $where, array( 'page_namespace != ' . NS_IMAGE ) );
 448+ $where['cl_type'] = array( 'page', 'subcat' );
449449 } else {
450 - $where['page_namespace'] = NS_CATEGORY;
 450+ $where['cl_type'] = 'subcat';
451451 }
452452 }
453453 }
@@ -461,7 +461,7 @@
462462 }
463463
464464 $res = $dbr->select( $tables, $fields, $where, __METHOD__,
465 - array( 'ORDER BY' => 'cl_sortkey', 'LIMIT' => $wgCategoryTreeMaxChildren ),
 465+ array( 'ORDER BY' => 'cl_type, cl_sortkey', 'LIMIT' => $wgCategoryTreeMaxChildren ),
466466 $joins );
467467
468468 # collect categories separately from other pages
@@ -574,7 +574,6 @@
575575 * $info must be an associative array, containing at least a Title object under the 'title' key.
576576 */
577577 function renderNodeInfo( $title, $cat, $children = 0, $loadchildren = false ) {
578 - global $wgCategoryTreeMaxScanRows;
579578 static $uniq = 0;
580579
581580 $mode = $this->getOption( 'mode' );
@@ -663,7 +662,7 @@
664663 $count = $pageCount;
665664 }
666665 }
667 - if ( $count === 0 || $pageCount > $wgCategoryTreeMaxScanRows ) {
 666+ if ( $count === 0 ) {
668667 $bullet = wfMsgNoTrans( 'categorytree-empty-bullet' ) . ' ';
669668 $attr['class'] = 'CategoryTreeEmptyBullet';
670669 } else {

Follow-up revisions

RevisionCommit summaryAuthorDate
r81671Back out the changes which depend on the categorylinks schema change, so that...tstarling00:57, 8 February 2011

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
r67179* Per Aryeh's suggestion on CR r66987, treat categories larger than a certain...tstarling08:58, 1 June 2010

Status & tagging log