r71902 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r71901‎ | r71902 | r71903 >
Date:21:21, 29 August 2010
Author:simetrical
Status:ok
Tags:
Comment:
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.
Modified paths:
  • /trunk/phase3/includes/CategoryPage.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/CategoryPage.php
@@ -585,12 +585,21 @@
586586 $totalrescnt = count( $this->articles ) + count( $this->children ) +
587587 ( $this->showGallery ? $this->gallery->count() : 0 );
588588
589 - if ( $dbcnt == $rescnt || ( ( $totalrescnt == $this->limit || $this->from
590 - || $this->until ) && $dbcnt > $rescnt ) )
 589+ # Check if there's a "from" or "until" for anything
 590+ $fromOrUntil = false;
 591+ foreach ( array( 'page', 'subcat', 'file' ) as $type ) {
 592+ if ( $this->from[$type] !== null || $this->until[$type] !== null ) {
 593+ $fromOrUntil = true;
 594+ break;
 595+ }
 596+ }
 597+
 598+ if ( $dbcnt == $rescnt || ( ( $totalrescnt == $this->limit || $fromOrUntil )
 599+ && $dbcnt > $rescnt ) )
591600 {
592601 # Case 1: seems sane.
593602 $totalcnt = $dbcnt;
594 - } elseif ( $totalrescnt < $this->limit && !$this->from && !$this->until ) {
 603+ } elseif ( $totalrescnt < $this->limit && !$fromOrUntil ) {
595604 # Case 2: not sane, but salvageable. Use the number of results.
596605 # Since there are fewer than 200, we can also take this opportunity
597606 # to refresh the incorrect category table entry -- which should be

Follow-up revisions

RevisionCommit summaryAuthorDate
r75856Fix bug caused by variable reuse from r71902maxsem15:52, 2 November 2010

Status & tagging log