Fix category count when category table out of sync
authorAryeh Gregor <simetrical@users.mediawiki.org>
Sun, 29 Aug 2010 21:21:57 +0000 (21:21 +0000)
committerAryeh Gregor <simetrical@users.mediawiki.org>
Sun, 29 Aug 2010 21:21:57 +0000 (21:21 +0000)
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

index d9ef507..c6a7f14 100644 (file)
@@ -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