mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/CategoryTree
synced 2024-11-27 09:43:06 +00:00
CategoryTree: Use Category::getMemberCount from core
Core now provides all-member count separately with type guarantee. Also bump core requirement to >= 1.38.0 Change-Id: I2b489e690ad05462a553e424bd9495593a8d2b1b
This commit is contained in:
parent
da1fd69a75
commit
de9a92c7a3
|
@ -6,7 +6,7 @@
|
|||
"license-name": "GPL-2.0-or-later",
|
||||
"type": "parserhook",
|
||||
"requires": {
|
||||
"MediaWiki": ">= 1.37.0"
|
||||
"MediaWiki": ">= 1.38.0"
|
||||
},
|
||||
"ConfigRegistry": {
|
||||
"categorytree": "GlobalVarConfig::newInstance"
|
||||
|
|
|
@ -631,11 +631,11 @@ class CategoryTree {
|
|||
if ( $ns === NS_CATEGORY ) {
|
||||
if ( $cat ) {
|
||||
if ( $mode === CategoryTreeMode::CATEGORIES ) {
|
||||
$count = intval( $cat->getSubcatCount() );
|
||||
$count = $cat->getSubcatCount();
|
||||
} elseif ( $mode === CategoryTreeMode::PAGES ) {
|
||||
$count = intval( $cat->getPageCount() ) - intval( $cat->getFileCount() );
|
||||
$count = $cat->getMemberCount() - $cat->getFileCount();
|
||||
} else {
|
||||
$count = intval( $cat->getPageCount() );
|
||||
$count = $cat->getMemberCount();
|
||||
}
|
||||
}
|
||||
if ( $count === 0 ) {
|
||||
|
@ -716,13 +716,10 @@ class CategoryTree {
|
|||
public static function createCountString( IContextSource $context, ?Category $cat,
|
||||
$countMode
|
||||
) {
|
||||
# Get counts, with conversion to integer so === works
|
||||
# Note: $allCount is the total number of cat members,
|
||||
# not the count of how many members are normal pages.
|
||||
$allCount = $cat ? intval( $cat->getPageCount() ) : 0;
|
||||
$subcatCount = $cat ? intval( $cat->getSubcatCount() ) : 0;
|
||||
$fileCount = $cat ? intval( $cat->getFileCount() ) : 0;
|
||||
$pages = $allCount - $subcatCount - $fileCount;
|
||||
$allCount = $cat ? $cat->getMemberCount() : 0;
|
||||
$subcatCount = $cat ? $cat->getSubcatCount() : 0;
|
||||
$fileCount = $cat ? $cat->getFileCount() : 0;
|
||||
$pages = $cat ? $cat->getPageCount( Category::COUNT_CONTENT_PAGES ) : 0;
|
||||
|
||||
$attr = [
|
||||
'title' => $context->msg( 'categorytree-member-counts' )
|
||||
|
|
Loading…
Reference in a new issue