Index: trunk/extensions/FlaggedRevs/FlaggedRevs.php |
— | — | @@ -461,6 +461,8 @@ |
462 | 462 | # Parser hooks, selects the desired images/templates |
463 | 463 | $wgHooks['BeforeParserFetchTemplateAndtitle'][] = 'FlaggedRevsHooks::parserFetchStableTemplate'; |
464 | 464 | $wgHooks['BeforeParserFetchFileAndTitle'][] = 'FlaggedRevsHooks::parserFetchStableFile'; |
| 465 | +# B/C for before ParserOutput::mImageTimeKeys |
| 466 | +$wgHooks['OutputPageParserOutput'][] = 'FlaggedRevsHooks::outputSetVersioningFlag'; |
465 | 467 | # ######## |
466 | 468 | |
467 | 469 | # ######## DB write operations ######### |
Index: trunk/extensions/FlaggedRevs/dataclasses/FlaggedRevs.hooks.php |
— | — | @@ -282,6 +282,17 @@ |
283 | 283 | } |
284 | 284 | |
285 | 285 | /** |
| 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 | + /** |
286 | 297 | * Check page move and patrol permissions for FlaggedRevs |
287 | 298 | */ |
288 | 299 | public static function onUserCan( Title $title, $user, $action, &$result ) { |
Index: trunk/extensions/FlaggedRevs/dataclasses/FlaggedRevs.class.php |
— | — | @@ -589,6 +589,15 @@ |
590 | 590 | return $parserOut; |
591 | 591 | } |
592 | 592 | |
| 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 | + |
593 | 602 | # ################ Tracking/cache update update functions ################# |
594 | 603 | |
595 | 604 | /** |
Index: trunk/extensions/FlaggedRevs/dataclasses/FRInclusionCache.php |
— | — | @@ -35,7 +35,8 @@ |
36 | 36 | $pOut = $parserCache->get( $article, $article->makeParserOptions( $author ) ); |
37 | 37 | } |
38 | 38 | } |
39 | | - if ( $pOut == false ) { |
| 39 | + // ParserOutput::mImageTimeKeys wasn't always there |
| 40 | + if ( $pOut == false || !FlaggedRevs::parserOutputIsVersioned( $pOut ) ) { |
40 | 41 | $title = $article->getTitle(); |
41 | 42 | $pOpts = ParserOptions::newFromUser( $user ); // Note: tidy off |
42 | 43 | # Disable slow crap that doesn't matter for getting templates/files... |
Index: trunk/extensions/FlaggedRevs/presentation/FlaggedPageView.php |
— | — | @@ -677,7 +677,11 @@ |
678 | 678 | $pOpts = $this->article->makeParserOptions( $wgUser ); |
679 | 679 | $parserCache = FRParserCacheStable::singleton(); |
680 | 680 | $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 ) ) ) { |
682 | 686 | # Cache hit. Note that redirects are not cached. |
683 | 687 | $this->addParserOutput( $parserOut ); |
684 | 688 | } else { |
— | — | @@ -1085,13 +1089,18 @@ |
1086 | 1090 | # Set the file version we are viewing (for File: pages) |
1087 | 1091 | $form->setFileVersion( $this->out->getFileVersion() ); |
1088 | 1092 | # $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 ) ) { |
1091 | 1097 | $tmpVers = $this->out->getTemplateIds(); |
1092 | 1098 | $fileVers = $this->out->getImageTimeKeys(); |
1093 | 1099 | } 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 |
1095 | 1102 | } 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. |
1096 | 1105 | list( $tmpVers, $fileVers ) = |
1097 | 1106 | FRInclusionCache::getRevIncludes( $this->article, $rev, $wgUser ); |
1098 | 1107 | } |