From 95d757240354d15576ad8e2085db0969859c561f Mon Sep 17 00:00:00 2001 From: Aryeh Gregor Date: Sun, 29 Aug 2010 21:21:57 +0000 Subject: [PATCH] Fix category count when category table out of sync This should fix a regression from my category sort work, caused by not accounting for the the fact that $this->from and $this->until were changed to arrays. Wrong counts for the number of pages in the category might have been displayed in some cases. --- includes/CategoryPage.php | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/includes/CategoryPage.php b/includes/CategoryPage.php index d9ef5077de..c6a7f146c1 100644 --- a/includes/CategoryPage.php +++ b/includes/CategoryPage.php @@ -585,12 +585,21 @@ class CategoryViewer { $totalrescnt = count( $this->articles ) + count( $this->children ) + ( $this->showGallery ? $this->gallery->count() : 0 ); - if ( $dbcnt == $rescnt || ( ( $totalrescnt == $this->limit || $this->from - || $this->until ) && $dbcnt > $rescnt ) ) + # Check if there's a "from" or "until" for anything + $fromOrUntil = false; + foreach ( array( 'page', 'subcat', 'file' ) as $type ) { + if ( $this->from[$type] !== null || $this->until[$type] !== null ) { + $fromOrUntil = true; + break; + } + } + + if ( $dbcnt == $rescnt || ( ( $totalrescnt == $this->limit || $fromOrUntil ) + && $dbcnt > $rescnt ) ) { # Case 1: seems sane. $totalcnt = $dbcnt; - } elseif ( $totalrescnt < $this->limit && !$this->from && !$this->until ) { + } elseif ( $totalrescnt < $this->limit && !$fromOrUntil ) { # Case 2: not sane, but salvageable. Use the number of results. # Since there are fewer than 200, we can also take this opportunity # to refresh the incorrect category table entry -- which should be -- 2.20.1