From 831d07a3a52c30fef4e81796b24a1f33d6aa3ea8 Mon Sep 17 00:00:00 2001 From: umherirrender Date: Thu, 16 Apr 2015 20:26:27 +0200 Subject: [PATCH] Show correct counts in category-info on action=info The number of pages was always the total count of all members of that category, not just pages. Correct that and also show the total count. Change-Id: I246d92b35d508e10fd93f9c7209db11a6e0eeb7a --- includes/actions/InfoAction.php | 18 +++++++++++++++--- languages/i18n/en.json | 1 + languages/i18n/qqq.json | 1 + 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/includes/actions/InfoAction.php b/includes/actions/InfoAction.php index 4f6efd46d1..de4f977dcb 100644 --- a/includes/actions/InfoAction.php +++ b/includes/actions/InfoAction.php @@ -373,18 +373,30 @@ class InfoAction extends FormlessAction { if ( $title->inNamespace( NS_CATEGORY ) ) { $category = Category::newFromTitle( $title ); + + // $allCount is the total number of cat members, + // not the count of how many members are normal pages. + $allCount = (int)$category->getPageCount(); + $subcatCount = (int)$category->getSubcatCount(); + $fileCount = (int)$category->getFileCount(); + $pagesCount = $allCount - $subcatCount - $fileCount; + $pageInfo['category-info'] = array( + array( + $this->msg( 'pageinfo-category-total' ), + $lang->formatNum( $allCount ) + ), array( $this->msg( 'pageinfo-category-pages' ), - $lang->formatNum( $category->getPageCount() ) + $lang->formatNum( $pagesCount ) ), array( $this->msg( 'pageinfo-category-subcats' ), - $lang->formatNum( $category->getSubcatCount() ) + $lang->formatNum( $subcatCount ) ), array( $this->msg( 'pageinfo-category-files' ), - $lang->formatNum( $category->getFileCount() ) + $lang->formatNum( $fileCount ) ) ); } diff --git a/languages/i18n/en.json b/languages/i18n/en.json index 1dfe21d095..90ee16b01a 100644 --- a/languages/i18n/en.json +++ b/languages/i18n/en.json @@ -2583,6 +2583,7 @@ "pageinfo-protect-cascading-yes": "Yes", "pageinfo-protect-cascading-from": "Protections are cascading from", "pageinfo-category-info": "Category information", + "pageinfo-category-total": "Total number of members", "pageinfo-category-pages": "Number of pages", "pageinfo-category-subcats": "Number of subcategories", "pageinfo-category-files": "Number of files", diff --git a/languages/i18n/qqq.json b/languages/i18n/qqq.json index d2da2b1f26..d7f2ebcb18 100644 --- a/languages/i18n/qqq.json +++ b/languages/i18n/qqq.json @@ -2751,6 +2751,7 @@ "pageinfo-protect-cascading-yes": "Yes, protections are cascading from here\n*{{msg-mw|Pageinfo-protect-cascading}}\n*{{msg-mw|Pageinfo-protect-cascading-yes}}\n{{Identical|Yes}}", "pageinfo-protect-cascading-from": "Key for a list of pages where protections are cascading from", "pageinfo-category-info": "Showed on the page displaying information about the current page (add \"?action=info\" to the URL)", + "pageinfo-category-total": "See also:\n* {{msg-mw|Pageinfo-category-pages}}\n* {{msg-mw|Pageinfo-category-subcats}}\n* {{msg-mw|Pageinfo-category-files}}", "pageinfo-category-pages": "See also:\n* {{msg-mw|Pageinfo-category-subcats}}\n* {{msg-mw|Pageinfo-category-files}}\n{{Identical|Number of pages}}", "pageinfo-category-subcats": "See also:\n* {{msg-mw|Pageinfo-category-pages}}\n* {{msg-mw|Pageinfo-category-files}}", "pageinfo-category-files": "See also:\n* {{msg-mw|Pageinfo-category-pages}}\n* {{msg-mw|Pageinfo-category-subcats}}", -- 2.20.1