Index: trunk/extensions/FlaggedRevs/FlaggedRevs.class.php |
— | — | @@ -486,26 +486,20 @@ |
487 | 487 | */ |
488 | 488 | public static function getRevCountSince( $article, $revId, $forUpdate=false ) { |
489 | 489 | global $wgMemc; |
490 | | - # Check if the count is zero by using $article->getLatest(). |
491 | | - # I don't trust using memcache and PHP for values like '0' |
492 | | - # as it may confuse "expired" with "0". |
493 | | - $latest = $forUpdate ? $article->getTitle()->getLatestRevID(GAID_FOR_UPDATE) : $article->getLatest(); |
494 | | - if( $latest == $revId ) { |
495 | | - return 0; |
496 | | - } |
497 | 490 | # Try the cache |
498 | 491 | $count = null; |
499 | 492 | $key = wfMemcKey( 'flaggedrevs', 'unreviewedrevs', $article->getId() ); |
500 | 493 | if( !$forUpdate ) { |
501 | | - $count = intval($wgMemc->get($key)); |
| 494 | + $val = $wgMemc->get($key); |
| 495 | + $count = is_integer($val) ? $val : null; |
502 | 496 | } |
503 | | - if( !$count ) { |
| 497 | + if( is_null($count) ) { |
504 | 498 | $db = $forUpdate ? wfGetDB( DB_MASTER) : wfGetDB( DB_SLAVE ); |
505 | 499 | $count = $db->selectField( 'revision', 'COUNT(*)', |
506 | 500 | array('rev_page' => $article->getId(), "rev_id > " . intval($revId) ), |
507 | 501 | __METHOD__ ); |
508 | 502 | # Save to cache |
509 | | - $wgMemc->set( $key, $count, 3600*24*7 ); |
| 503 | + $wgMemc->set( $key, intval($count), 3600*24*7 ); |
510 | 504 | } |
511 | 505 | return $count; |
512 | 506 | } |