mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/CategoryTree
synced 2024-11-15 03:43:55 +00:00
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.
This commit is contained in:
parent
e2300181e5
commit
064ce8137b
|
@ -37,7 +37,6 @@ define( 'CT_HIDEPREFIX_AUTO', 30 );
|
|||
* Options:
|
||||
*
|
||||
* $wgCategoryTreeMaxChildren - maximum number of children shown in a tree node. Default is 200
|
||||
* $wgCategoryTreeMaxScanRows - maximum number of rows the DBMS may scan while showing a tree node.
|
||||
* $wgCategoryTreeAllowTag - enable <categorytree> tag. Default is true.
|
||||
* $wgCategoryTreeDynamicTag - loads the first level of the tree in a <categorytag> dynamically.
|
||||
* This way, the cache does not need to be disabled. Default is false.
|
||||
|
@ -53,7 +52,6 @@ define( 'CT_HIDEPREFIX_AUTO', 30 );
|
|||
*/
|
||||
|
||||
$wgCategoryTreeMaxChildren = 200;
|
||||
$wgCategoryTreeMaxScanRows = 10000;
|
||||
$wgCategoryTreeAllowTag = true;
|
||||
$wgCategoryTreeDisableCache = true;
|
||||
$wgCategoryTreeDynamicTag = false;
|
||||
|
|
|
@ -444,9 +444,9 @@ class CategoryTree {
|
|||
$where['page_namespace'] = $namespaces;
|
||||
} elseif ( $mode != CT_MODE_ALL ) {
|
||||
if ( $mode == CT_MODE_PAGES ) {
|
||||
$where = array_merge( $where, array( 'page_namespace != ' . NS_IMAGE ) );
|
||||
$where['cl_type'] = array( 'page', 'subcat' );
|
||||
} else {
|
||||
$where['page_namespace'] = NS_CATEGORY;
|
||||
$where['cl_type'] = 'subcat';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -461,7 +461,7 @@ class CategoryTree {
|
|||
}
|
||||
|
||||
$res = $dbr->select( $tables, $fields, $where, __METHOD__,
|
||||
array( 'ORDER BY' => 'cl_sortkey', 'LIMIT' => $wgCategoryTreeMaxChildren ),
|
||||
array( 'ORDER BY' => 'cl_type, cl_sortkey', 'LIMIT' => $wgCategoryTreeMaxChildren ),
|
||||
$joins );
|
||||
|
||||
# collect categories separately from other pages
|
||||
|
@ -574,7 +574,6 @@ class CategoryTree {
|
|||
* $info must be an associative array, containing at least a Title object under the 'title' key.
|
||||
*/
|
||||
function renderNodeInfo( $title, $cat, $children = 0, $loadchildren = false ) {
|
||||
global $wgCategoryTreeMaxScanRows;
|
||||
static $uniq = 0;
|
||||
|
||||
$mode = $this->getOption( 'mode' );
|
||||
|
@ -663,7 +662,7 @@ class CategoryTree {
|
|||
$count = $pageCount;
|
||||
}
|
||||
}
|
||||
if ( $count === 0 || $pageCount > $wgCategoryTreeMaxScanRows ) {
|
||||
if ( $count === 0 ) {
|
||||
$bullet = wfMsgNoTrans( 'categorytree-empty-bullet' ) . ' ';
|
||||
$attr['class'] = 'CategoryTreeEmptyBullet';
|
||||
} else {
|
||||
|
|
Loading…
Reference in a new issue