From: Aryeh Gregor Date: Sun, 29 Aug 2010 21:21:57 +0000 (+0000) Subject: Fix category count when category table out of sync X-Git-Tag: 1.31.0-rc.0~35278 X-Git-Url: http://git.cyclocoop.org/%22%20.%20generer_url_ecrire%28%22suivi_revisions%22%29%20.%20%22?a=commitdiff_plain;h=95d757240354d15576ad8e2085db0969859c561f;p=lhc%2Fweb%2Fwiklou.git 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. --- 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