r40499 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r40498‎ | r40499 | r40500 >
Date:16:31, 5 September 2008
Author:simetrical
Status:old
Tags:
Comment:
Refresh category table counts sometimes for small categories

When someone views a category page, if the number of retrieved pages is the whole category (no from= or until=, 200 or less retrieved), and that number doesn't match the number in the category table, we already detect that this is wrong and ignore the bogus category table number. Now the software also refreshes the bogus category counts in the database in this case, which should be pretty much instantaneous since it has less than 200 entries.

This adds no overhead for categories that have correct counts, and fixes the most visible case when category counts are wrong: small categories, when you can easily count the pages.
Modified paths:
  • /trunk/phase3/includes/Category.php (modified) (history)
  • /trunk/phase3/includes/CategoryPage.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/CategoryPage.php
@@ -500,8 +500,12 @@
501501 # Case 1: seems sane.
502502 $totalcnt = $dbcnt;
503503 } elseif($totalrescnt < $this->limit && !$this->from && !$this->until){
504 - # Case 2: not sane, but salvageable.
 504+ # Case 2: not sane, but salvageable. Use the number of results.
 505+ # Since there are fewer than 200, we can also take this opportunity
 506+ # to refresh the incorrect category table entry -- which should be
 507+ # quick due to the small number of entries.
505508 $totalcnt = $rescnt;
 509+ $this->cat->refreshCounts();
506510 } else {
507511 # Case 3: hopeless. Don't give a total count at all.
508512 return wfMsgExt("category-$type-count-limited", 'parse',