From ce5a36ab59c235753541f31c3c970bbe12222896 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Bartosz=20Dziewo=C5=84ski?= Date: Mon, 29 Feb 2016 23:05:32 +0100 Subject: [PATCH] CategoryViewer: Do opportunistic category recounts for mismatched file counts, too There are some categories on Commons that have no files, but are recorded to have some, e.g. [1] appears to have 15 files [2]. We have logic to fix these, but it wasn't being checked for file counts (only pages and subcats). [1] https://commons.wikimedia.org/wiki/Category:Police_of_Mexico,_D._F._vehicles [2] https://commons.wikimedia.org/w/index.php?title=Category:Police_of_Mexico,_D._F._vehicles&action=info Change-Id: If88fc15347eb592e957452884c2179d7c237bd2c --- includes/CategoryViewer.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/includes/CategoryViewer.php b/includes/CategoryViewer.php index b912603611..f7490033d4 100644 --- a/includes/CategoryViewer.php +++ b/includes/CategoryViewer.php @@ -387,6 +387,7 @@ class CategoryViewer extends ContextSource { $r = ''; $rescnt = count( $this->children ); $dbcnt = $this->cat->getSubcatCount(); + // This function should be called even if the result isn't used, it has side-effects $countmsg = $this->getCountMessage( $rescnt, $dbcnt, 'subcat' ); if ( $rescnt > 0 ) { @@ -417,6 +418,7 @@ class CategoryViewer extends ContextSource { $dbcnt = $this->cat->getPageCount() - $this->cat->getSubcatCount() - $this->cat->getFileCount(); $rescnt = count( $this->articles ); + // This function should be called even if the result isn't used, it has side-effects $countmsg = $this->getCountMessage( $rescnt, $dbcnt, 'article' ); if ( $rescnt > 0 ) { @@ -437,10 +439,11 @@ class CategoryViewer extends ContextSource { function getImageSection() { $r = ''; $rescnt = $this->showGallery ? $this->gallery->count() : count( $this->imgsNoGallery ); - if ( $rescnt > 0 ) { - $dbcnt = $this->cat->getFileCount(); - $countmsg = $this->getCountMessage( $rescnt, $dbcnt, 'file' ); + $dbcnt = $this->cat->getFileCount(); + // This function should be called even if the result isn't used, it has side-effects + $countmsg = $this->getCountMessage( $rescnt, $dbcnt, 'file' ); + if ( $rescnt > 0 ) { $r .= "
\n"; $r .= '

' . $this->msg( -- 2.20.1