r96164 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r96163‎ | r96164 | r96165 >
Date:23:19, 2 September 2011
Author:aaron
Status:ok
Tags:
Comment:
Follow-up r96163: changed r84610 et al FlaggedRevs code to deal with parser output objects that lack mImageTimeKeys
Modified paths:
  • /trunk/extensions/FlaggedRevs/FlaggedRevs.php (modified) (history)
  • /trunk/extensions/FlaggedRevs/dataclasses/FRInclusionCache.php (modified) (history)
  • /trunk/extensions/FlaggedRevs/dataclasses/FlaggedRevs.class.php (modified) (history)
  • /trunk/extensions/FlaggedRevs/dataclasses/FlaggedRevs.hooks.php (modified) (history)
  • /trunk/extensions/FlaggedRevs/presentation/FlaggedPageView.php (modified) (history)

Diff [purge]

Index: trunk/extensions/FlaggedRevs/FlaggedRevs.php
@@ -461,6 +461,8 @@
462462 # Parser hooks, selects the desired images/templates
463463 $wgHooks['BeforeParserFetchTemplateAndtitle'][] = 'FlaggedRevsHooks::parserFetchStableTemplate';
464464 $wgHooks['BeforeParserFetchFileAndTitle'][] = 'FlaggedRevsHooks::parserFetchStableFile';
 465+# B/C for before ParserOutput::mImageTimeKeys
 466+$wgHooks['OutputPageParserOutput'][] = 'FlaggedRevsHooks::outputSetVersioningFlag';
465467 # ########
466468
467469 # ######## DB write operations #########
Index: trunk/extensions/FlaggedRevs/dataclasses/FlaggedRevs.hooks.php
@@ -282,6 +282,17 @@
283283 }
284284
285285 /**
 286+ * Detect if a ParserOutput object was added without mImageTimeKeys set.
 287+ * This is needed for older, cached, ParserOutput objects.
 288+ */
 289+ public static function outputSetVersioningFlag( OutputPage $out, ParserOutput $parserOut ) {
 290+ if ( !FlaggedRevs::parserOutputIsVersioned( $parserOut ) ) {
 291+ $out->fr_unversionedIncludes = true;
 292+ }
 293+ return true;
 294+ }
 295+
 296+ /**
286297 * Check page move and patrol permissions for FlaggedRevs
287298 */
288299 public static function onUserCan( Title $title, $user, $action, &$result ) {
Index: trunk/extensions/FlaggedRevs/dataclasses/FlaggedRevs.class.php
@@ -589,6 +589,15 @@
590590 return $parserOut;
591591 }
592592
 593+ /**
 594+ * Check that ParserOutput object has file/template versions
 595+ * Note that ParserOutput::mImageTimeKeys wasn't always there
 596+ * @return bool
 597+ */
 598+ public static function parserOutputIsVersioned( ParserOutput $pOut ) {
 599+ return ( $pOut->getTemplateIds() !== null && $pOut->getImageTimeKeys() !== null );
 600+ }
 601+
593602 # ################ Tracking/cache update update functions #################
594603
595604 /**
Index: trunk/extensions/FlaggedRevs/dataclasses/FRInclusionCache.php
@@ -35,7 +35,8 @@
3636 $pOut = $parserCache->get( $article, $article->makeParserOptions( $author ) );
3737 }
3838 }
39 - if ( $pOut == false ) {
 39+ // ParserOutput::mImageTimeKeys wasn't always there
 40+ if ( $pOut == false || !FlaggedRevs::parserOutputIsVersioned( $pOut ) ) {
4041 $title = $article->getTitle();
4142 $pOpts = ParserOptions::newFromUser( $user ); // Note: tidy off
4243 # Disable slow crap that doesn't matter for getting templates/files...
Index: trunk/extensions/FlaggedRevs/presentation/FlaggedPageView.php
@@ -677,7 +677,11 @@
678678 $pOpts = $this->article->makeParserOptions( $wgUser );
679679 $parserCache = FRParserCacheStable::singleton();
680680 $parserOut = $parserCache->get( $this->article, $pOpts );
681 - if ( $parserOut ) {
 681+
 682+ # Do not use the parser cache if it lacks mImageTimeKeys and there is a
 683+ # chance that a review form will be added to this page (which requires the versions).
 684+ $canReview = $this->article->getTitle()->userCan( 'review' );
 685+ if ( $parserOut && ( !$canReview || FlaggedRevs::parserOutputIsVersioned( $parserOut ) ) ) {
682686 # Cache hit. Note that redirects are not cached.
683687 $this->addParserOutput( $parserOut );
684688 } else {
@@ -1085,13 +1089,18 @@
10861090 # Set the file version we are viewing (for File: pages)
10871091 $form->setFileVersion( $this->out->getFileVersion() );
10881092 # $wgOut may not already have the inclusion IDs, such as for diffonly=1.
1089 - # RevisionReviewForm will fetch them as needed however.
1090 - if ( $this->out->getRevisionId() == $rev->getId() ) {
 1093+ # fr_unversionedIncludes indicates that ParserOutput added to $wgOut lacked inclusion IDs.
 1094+ # If they're lacking, then we use getRevIncludes() to get the draft inclusion versions.
 1095+ # Note: showStableVersion() already makes sure that $wgOut has the stable inclusion versions.
 1096+ if ( $this->out->getRevisionId() == $rev->getId() && empty( $this->out->fr_unversionedIncludes ) ) {
10911097 $tmpVers = $this->out->getTemplateIds();
10921098 $fileVers = $this->out->getImageTimeKeys();
10931099 } elseif ( $this->oldRevIncludes ) { // e.g. diffonly=1, stable diff
1094 - list( $tmpVers, $fileVers ) = $this->oldRevIncludes;
 1100+ # We may have already fetched the inclusion IDs to get the template/file changes.
 1101+ list( $tmpVers, $fileVers ) = $this->oldRevIncludes; // reuse
10951102 } else { // e.g. diffonly=1, other diffs
 1103+ # $wgOut may not already have the inclusion IDs, such as for diffonly=1.
 1104+ # RevisionReviewForm will fetch them as needed however.
10961105 list( $tmpVers, $fileVers ) =
10971106 FRInclusionCache::getRevIncludes( $this->article, $rev, $wgUser );
10981107 }

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r84610* Put parser output file version tracking to core...aaron17:35, 23 March 2011
r96163Reverted parser bump from r84601 per CRaaron23:14, 2 September 2011

Status & tagging log