Revision: 46121
Author: aaron
Date: 2009-01-24 06:41:34 +0000 (Sat, 24 Jan 2009)
Log Message:
-----------
Cache tweaks and fixes
Modified Paths:
--------------
trunk/extensions/FlaggedRevs/specialpages/RatingHistory_body.php
trunk/extensions/FlaggedRevs/specialpages/ReaderFeedback_body.php
Modified: trunk/extensions/FlaggedRevs/specialpages/RatingHistory_body.php
===================================================================
--- trunk/extensions/FlaggedRevs/specialpages/RatingHistory_body.php
2009-01-24 06:27:28 UTC (rev 46120)
+++ trunk/extensions/FlaggedRevs/specialpages/RatingHistory_body.php
2009-01-24 06:41:34 UTC (rev 46121)
@@ -58,7 +58,7 @@
/*
* Allow client caching.
*/
- if( !$this->doPurge && $wgOut->checkLastModified(
$this->getTouched() ) ) {
+ if( !$this->doPurge && $wgOut->checkLastModified(
self::getTouched($this->page) ) ) {
return; // Client cache fresh and headers sent, nothing
more to do
} else {
$wgOut->enableClientCache( false ); // don't show stale
graphs
@@ -623,14 +623,18 @@
public static function getVoteAggregates( $page, $period ) {
global $wgMemc;
// Check cache
- $key = wfMemcKey( 'flaggedrevs', 'ratingtally',
$page->getArticleId() );
+ $key = wfMemcKey( 'flaggedrevs', 'ratingtally',
$page->getArticleId(), $period );
$set = $wgMemc->get($key);
- // Cutoff is at the 24 hour mark due to the way the aggregate
schema
- // groups ratings by data for graphs.
+ // Cutoff is at the 24 hour mark due to the way the aggregate
+ // schema groups ratings by data for graphs.
$now = time();
$cache_cutoff = $now - ($now % 86400);
- if( is_array($set) && $set[1] > $cache_cutoff ) {
- $votes = $set[0];
+ if( is_array($set) ) {
+ list($val,$time) = $set;
+ $touched = wfTimestamp( TS_UNIX,
self::getTouched($page) );
+ if( $time > $cache_cutoff && $time > $touched ) {
+ $votes = $val;
+ }
}
// Do query, cache miss
if( !isset($votes) ) {
@@ -744,13 +748,14 @@
/**
* Get highest touch timestamp of the tags. This uses a tiny filesort.
+ * @param $page Title
* @returns string
*/
- public function getTouched() {
+ public static function getTouched( $page ) {
$dbr = wfGetDB( DB_SLAVE );
$tagTimestamp = $dbr->selectField( 'reader_feedback_pages',
'MAX(rfp_touched)',
- array( 'rfp_page_id' => $this->page->getArticleId() ),
+ array( 'rfp_page_id' => $page->getArticleId() ),
__METHOD__ );
return wfTimestamp( TS_MW, $tagTimestamp );
}
Modified: trunk/extensions/FlaggedRevs/specialpages/ReaderFeedback_body.php
===================================================================
--- trunk/extensions/FlaggedRevs/specialpages/ReaderFeedback_body.php
2009-01-24 06:27:28 UTC (rev 46120)
+++ trunk/extensions/FlaggedRevs/specialpages/ReaderFeedback_body.php
2009-01-24 06:41:34 UTC (rev 46121)
@@ -164,6 +164,8 @@
$graphLink = SpecialPage::getTitleFor( 'RatingHistory'
)->getFullUrl( 'target='.$form->page->getPrefixedUrl() );
$talk = $form->page->getTalkPage();
+ $tallyTable = RatingHistory::getVoteAggregates( $form->page, 31
);
+
$dbw = wfGetDB( DB_MASTER );
$dbw->begin();
$ok = ( $bot || $form->submit() ); // don't submit for mindless
drones
@@ -173,11 +175,11 @@
if( $ok ) {
return '<suc#>'.wfMsgExt( 'readerfeedback-success',
array('parseinline'),
$form->page->getPrefixedText(), $graphLink,
$talk->getFullUrl( 'action=edit§ion=new' ) ) .
-
'<h4>'.wfMsgHtml('ratinghistory-table')."</h4>\n".RatingHistory::getVoteAggregates(
$form->page, 31 );
+
'<h4>'.wfMsgHtml('ratinghistory-table')."</h4>\n$tallyTable";
} else {
return '<err#>'.wfMsgExt( 'readerfeedback-voted',
array('parseinline'),
$form->page->getPrefixedText(), $graphLink,
$talk->getFullUrl( 'action=edit§ion=new' ) ) .
-
'<h4>'.wfMsgHtml('ratinghistory-table')."</h4>\n".RatingHistory::getVoteAggregates(
$form->page, 31 );
+
'<h4>'.wfMsgHtml('ratinghistory-table')."</h4>\n$tallyTable";
}
}
_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs