r20760 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r20759‎ | r20760 | r20761 >
Date:02:11, 28 March 2007
Author:aaron
Status:old
Tags:
Comment:
*Use cachkeys, more general
Modified paths:
  • /branches/jhb/phase3/extensions/FlaggedRevs.php (modified) (history)
  • /branches/jhb/phase3/extensions/FlaggedRevs.sql (modified) (history)
  • /branches/jhb/phase3/extensions/FlaggedRevsPage.i18n.php (modified) (history)

Diff [purge]

Index: branches/jhb/phase3/extensions/FlaggedRevs.php
@@ -270,19 +270,16 @@
271271 $newbodytext = NULL;
272272 # Try the stable cache for non-users
273273 # Users have skin prefs and this caching won't work
274 - if ( $wgUser->isAnon() ) {
275 - $newbodytext = $this->getPageCache( $wgArticle );
276 - }
 274+ $newbodytext = $this->getPageCache( $wgArticle );
277275 # If no cache is available, get the text and parse it
278276 if ( is_null($newbodytext) ) {
279277 $text = $this->getFlaggedRevText( $visible_id );
280278 # For anons, use standard prefs, for users, get theirs
281 - $options = ( $wgUser->isAnon() ) ? new ParserOptions() : ParserOptions::newFromUser($wgUser);
 279+ $options = ParserOptions::newFromUser($wgUser);
282280 # Parsing this text is kind of funky...
283281 $newbodytext = $this->parseStableText( $wgTitle, $text, $visible_id, $options );
284282 # Update the general cache for non-users
285 - if ( $wgUser->isAnon() )
286 - $this->updatePageCache( $wgArticle, $newbodytext );
 283+ $this->updatePageCache( $wgArticle, $newbodytext );
287284 }
288285 }
289286 // Construct some tagging
@@ -460,7 +457,7 @@
461458 } else if( $ontop ) {
462459 $wgOut->addHTML( $form );
463460 } else {
464 - $wgOut->addHTML( '<hr/>' . $form );
 461+ $wgOut->addHTML( $form );
465462 }
466463 }
467464
@@ -474,7 +471,7 @@
475472 $notes = ($breakline) ? '<hr/><br/>' : '';
476473 $notes .= '<div class="mw-warning plainlinks">';
477474 $notes .= wfMsgExt('revreview-note', array('parse'), User::whoIs( $row->fr_user ) );
478 - $notes .= $this->skin->formatComment( $row->fr_comment ) . "</div>";
 475+ $notes .= '<i>' . $this->skin->formatComment( $row->fr_comment ) . '</i></div>';
479476 $wgOut->addHTML( $notes );
480477 }
481478 }
@@ -707,16 +704,20 @@
708705 }
709706
710707 function getPageCache( $article ) {
 708+ global $wgUser;
 709+
711710 wfProfileIn( __METHOD__ );
712711
713712 // Make sure it is valid
714713 if ( !$article || !$article->getId() ) return NULL;
 714+ $cachekey = ParserCache::getKey( $article, $wgUser );
 715+
715716 $db = wfGetDB( DB_SLAVE );
716717 // Replace the page cache if it is out of date
717718 $result = $db->select(
718719 array('flaggedcache'),
719720 array('fc_cache'),
720 - array('fc_page_id' => $article->getId(), 'fc_date >= ' . $article->getTouched() ),
 721+ array('fc_key' => $cachekey, 'fc_date >= ' . $article->getTouched() ),
721722 __METHOD__);
722723 if ( $row = $db->fetchObject($result) ) {
723724 return $row->fc_cache;
@@ -725,19 +726,21 @@
726727 }
727728
728729 function updatePageCache( $article, $value=NULL ) {
 730+ global $wgUser;
729731 wfProfileIn( __METHOD__ );
730732
731733 // Make sure it is valid
732734 if ( is_null($value) || !$article || !$article->getId() ) return false;
 735+ $cachekey = ParserCache::getKey( $article, $wgUser );
733736 // Add cache mark
734737 $timestamp = wfTimestampNow();
735 - $value .= "\n<!-- Saved in stable version parser cache for page id #".$article->getId()." with timestamp $timestamp -->";
 738+ $value .= "\n<!-- Saved in stable version parser cache for key $cachekey with timestamp $timestamp -->";
736739
737740 $dbw = wfGetDB( DB_MASTER );
738741 // Replace the page cache if it is out of date
739742 $dbw->replace('flaggedcache',
740 - array('fc_page_id'),
741 - array('fc_page_id' => $article->getId(), 'fc_cache' => $value, 'fc_date' => $timestamp),
 743+ array('fc_key'),
 744+ array('fc_key' => $cachekey, 'fc_cache' => $value, 'fc_date' => $timestamp),
742745 __METHOD__);
743746
744747 return true;
Index: branches/jhb/phase3/extensions/FlaggedRevs.sql
@@ -46,9 +46,9 @@
4747
4848 -- This stores cached text for page view
4949 CREATE TABLE /*$wgDBprefix*/flaggedcache (
50 - fc_page_id int(10) NOT NULL,
 50+ fc_key char(255) binary NOT NULL default '',
5151 fc_cache mediumblob NOT NULL default '',
5252 fc_date char(14) NOT NULL,
5353
54 - PRIMARY KEY fc_page_id (fc_page_id)
 54+ PRIMARY KEY fc_key (fc_key)
5555 ) TYPE=InnoDB;
\ No newline at end of file
Index: branches/jhb/phase3/extensions/FlaggedRevsPage.i18n.php
@@ -35,8 +35,8 @@
3636 than the top revision. The content of this approved revision will remain constant regardless of any transcluded
3737 pages or internal images. Users on this wiki will still be able to access
3838 unreviewed content through the page history.",
39 - 'revreview-images' => 'Internal images on this page will be copied to the stable image directory and stored
40 - there until no reviewed revisions use them. The following images are transcluded onto this page:',
 39+ 'revreview-images' => 'Internal images on this page will be copied to the stable image directory, updating
 40+ existing versions, and stored there until no reviewed revisions use them. The following images are transcluded onto this page:',
4141
4242 'revreview-hist' => '[reviewed]',
4343