r30814 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r30813‎ | r30814 | r30815 >
Date:23:44, 10 February 2008
Author:aaron
Status:old
Tags:
Comment:
* Make sure output metadata is included
* Tweak parsing/caching
Modified paths:
  • /trunk/extensions/FlaggedRevs/FlaggedArticle.php (modified) (history)
  • /trunk/extensions/FlaggedRevs/FlaggedRevs.php (modified) (history)
  • /trunk/extensions/FlaggedRevs/FlaggedRevsPage.php (modified) (history)

Diff [purge]

Index: trunk/extensions/FlaggedRevs/FlaggedRevs.php
@@ -525,7 +525,7 @@
526526 return new FlaggedRevision( $row );
527527 }
528528
529 - return NULL;
 529+ return null;
530530 }
531531
532532 /**
@@ -774,7 +774,7 @@
775775 wfProfileIn( __METHOD__ );
776776 # Make sure it is valid
777777 if( !$article->getId() )
778 - return NULL;
 778+ return null;
779779
780780 $parserCache = ParserCache::singleton();
781781 $key = self::getCacheKey( $parserCache, $article, $wgUser );
@@ -828,13 +828,11 @@
829829 * @param parerOutput $parserOut
830830 * Updates the stable cache of a page with the given $parserOut
831831 */
832 - public static function updatePageCache( $article, $parserOut=NULL ) {
 832+ public static function updatePageCache( $article, $parserOut=null ) {
833833 global $wgUser, $parserMemc, $wgParserCacheExpireTime;
834834 # Make sure it is valid
835835 if( is_null($parserOut) || !$article )
836836 return false;
837 - # Update the cache...
838 - $article->getTitle()->invalidateCache();
839837
840838 $parserCache = ParserCache::singleton();
841839 $key = self::getCacheKey( $parserCache, $article, $wgUser );
@@ -852,8 +850,6 @@
853851 }
854852 # Save to objectcache
855853 $parserMemc->set( $key, $parserOut, $expire );
856 - # Purge squid for this page only
857 - $article->getTitle()->purgeSquid();
858854
859855 return true;
860856 }
@@ -1144,16 +1140,18 @@
11451141 return true;
11461142 # Get the either the full flagged revision text or the revision text
11471143 $article = new Article( $linksUpdate->mTitle );
1148 - if( $wgUseStableTemplates ) {
1149 - $rev = Revision::newFromId( $sv->getRevId() );
1150 - $text = $rev->getText();
1151 - } else {
1152 - $text = $sv->getText();
 1144+ # Try stable version cache. This should be updated before this is called.
 1145+ $parserOut = self::getPageCache( $article );
 1146+ if( $parserOut==false ) {
 1147+ if( $wgUseStableTemplates ) {
 1148+ $rev = Revision::newFromId( $sv->getRevId() );
 1149+ $text = $rev->getText();
 1150+ } else {
 1151+ $text = $sv->getText();
 1152+ }
 1153+ # Parse the text
 1154+ $parserOut = self::parseStableText( $article, $text, $sv->getRevId() );
11531155 }
1154 - # Parse the text
1155 - $parserOut = self::parseStableText( $article, $text, $sv->getRevId() );
1156 - # Might as well update the stable cache while we're at it
1157 - self::updatePageCache( $article, $parserOut );
11581156 # Update page fields
11591157 self::updateArticleOn( $article, $sv->getRevId() );
11601158 # Update the links tables to include these
@@ -1390,8 +1388,8 @@
13911389 $parser->mOutput->fr_newestImageTime = $maxTimestamp;
13921390 # Record the max template revision ID
13931391 if( !empty($parser->mOutput->mTemplateIds) ) {
1394 - foreach( $parser->mOutput->mTemplateIds as $namespace => $title_rev ) {
1395 - foreach( $title_rev as $title => $revID ) {
 1392+ foreach( $parser->mOutput->mTemplateIds as $namespace => $DBkey_rev ) {
 1393+ foreach( $DBkey_rev as $DBkey => $revID ) {
13961394 if( $revID > $maxRevision ) {
13971395 $maxRevision = $revID;
13981396 }
@@ -1410,8 +1408,6 @@
14111409 # Leave as defaults if missing. Relevant things will be updated only when needed.
14121410 # We don't want to go around resetting caches all over the place if avoidable...
14131411 $out->fr_ImageSHA1Keys = isset($parserOut->fr_ImageSHA1Keys) ? $parserOut->fr_ImageSHA1Keys : array();
1414 - $out->fr_newestImageTime = isset($parserOut->fr_newestImageTime) ? $parserOut->fr_newestImageTime : "0";
1415 - $out->fr_newestTemplateID = isset($parserOut->fr_newestTemplateID) ? $parserOut->fr_newestTemplateID : 0;
14161412
14171413 return true;
14181414 }
@@ -1560,7 +1556,7 @@
15611557 * Get a selector of reviewable namespaces
15621558 * @param int $selected, namespace selected
15631559 */
1564 - public static function getNamespaceMenu( $selected=NULL ) {
 1560+ public static function getNamespaceMenu( $selected=null ) {
15651561 global $wgContLang, $wgFlaggedRevsNamespaces;
15661562
15671563 $selector = "<label for='namespace'>" . wfMsgHtml('namespace') . "</label>";
Index: trunk/extensions/FlaggedRevs/FlaggedArticle.php
@@ -886,11 +886,7 @@
887887 $extraq .= "oldid={$frev->getRevId()}&diff=cur&editreview=1";
888888 } else {
889889 if( !is_null($frev) ){
890 - if( $wgUser->isAllowed('review') ) {
891 - $extraq .= "stable=1";
892 - } else {
893 - $extraq .= "stable=0";
894 - }
 890+ $extraq .= "stable=0";
895891 }
896892 }
897893
Index: trunk/extensions/FlaggedRevs/FlaggedRevsPage.php
@@ -399,8 +399,10 @@
400400 $dbw->rollback(); // All versions must be specified, 0 for none
401401 return false;
402402 }
 403+
 404+ $article = new Article( $this->page );
403405 # Check if the rest matches up
404 - $stableOutput = FlaggedRevs::parseStableText( new Article( $rev->getTitle() ), $fulltext, $rev->getId() );
 406+ $stableOutput = FlaggedRevs::parseStableText( $article, $rev->getText(), $rev->getId() );
405407 if( !$stableOutput->fr_includesMatched ) {
406408 $dbw->rollback(); // All versions must be specified, 0 for none
407409 return false;
@@ -443,6 +445,7 @@
444446 'fr_text' => $fulltext, # Store expanded text for speed
445447 'fr_flags' => $textFlags
446448 );
 449+
447450 # Update flagged revisions table
448451 $dbw->replace( 'flaggedrevs', array( array('fr_page_id','fr_rev_id') ), $revset, __METHOD__ );
449452 # Mark as patrolled
@@ -457,8 +460,8 @@
458461 # Update the article review log
459462 $this->updateLog( $this->page, $this->dims, $this->comment, $this->oldid, true );
460463
461 - $article = new Article( $this->page );
462 - # Update the links tables as the stable version may now be the default page...
 464+ # Update the links tables as the stable version may now be the default page.
 465+ # Try using the parser cache first since we didn't actually edit the current version.
463466 $parserCache = ParserCache::singleton();
464467 $poutput = $parserCache->get( $article, $wgUser );
465468 if( $poutput==false ) {
@@ -467,15 +470,18 @@
468471 $options->setTidy(true);
469472 $poutput = $wgParser->parse( $text, $article->mTitle, $options );
470473 }
 474+ # Clear the cache...
 475+ $this->page->invalidateCache();
 476+ # Might as well update the stable cache while we're at it
 477+ FlaggedRevs::updatePageCache( $article, $stableOutput );
 478+
471479 $u = new LinksUpdate( $this->page, $poutput );
472480 $u->doUpdate(); // Will trigger our hook to add stable links too...
473481
474 - # Clear the cache...
475 - $this->page->invalidateCache();
476 - # Might as well save the cache
 482+ # Might as well save the cache, since it should be the same
477483 $parserCache->save( $poutput, $article, $wgUser );
478484 # Purge squid for this page only
479 - $this->page->purgeSquid();
 485+ $article->getTitle()->purgeSquid();
480486
481487 return true;
482488 }

Status & tagging log