Index: trunk/extensions/FlaggedRevs/FlaggedRevs.php |
— | — | @@ -10,6 +10,7 @@ |
11 | 11 | define('FLAGGED_CSS', $wgScriptPath.'/extensions/FlaggedRevs/flaggedrevs.css' ); |
12 | 12 | if( !defined( 'FLAGGED_JS' ) ) |
13 | 13 | define('FLAGGED_JS', $wgScriptPath.'/extensions/FlaggedRevs/flaggedrevs.js' ); |
| 14 | + |
14 | 15 | if( !defined( 'FLAGGED_VIS_NORMAL' ) ) |
15 | 16 | define('FLAGGED_VIS_NORMAL',0); |
16 | 17 | if( !defined( 'FLAGGED_VIS_LATEST' ) ) |
— | — | @@ -166,13 +167,22 @@ |
167 | 168 | # Auto-review new pages with the minimal level? |
168 | 169 | $wgFlaggedRevsAutoReviewNew = false; |
169 | 170 | |
170 | | -# How long to cache stable versions? (seconds) |
171 | | -$wgFlaggedRevsExpire = 7 * 24 * 3600; |
172 | 171 | # Compress pre-processed flagged revision text? |
173 | 172 | $wgFlaggedRevsCompression = false; |
174 | 173 | |
175 | | -# If a template to be transcluded has a stable version, use that |
176 | | -$wgFlaggedRevsStableTemplates = false; |
| 174 | +# When parsing a reviewed revision, if a template to be transcluded |
| 175 | +# has a stable version, use that version. If not present, use the one |
| 176 | +# specified when the reviewed revision was reviewed. |
| 177 | +$wgUseStableTemplates = false; |
| 178 | +# We may have templates that do not have stable version. Given situational |
| 179 | +# inclusion of templates (such as parser functions that select template |
| 180 | +# X or Y depending), there may also be no ID pointed to by the metadata |
| 181 | +# of how the article was when it was reviewed. An example would be an |
| 182 | +# article that selects a template based on time. The template to be |
| 183 | +# selected will change, and the metadata only points to the reviewed ID |
| 184 | +# of the old template. This can be a problem if $wgUseStableTemplates is |
| 185 | +# enabled. In such cases, we can select the current (unreviewed) revision. |
| 186 | +$wgUseCurrentTemplates = false; |
177 | 187 | |
178 | 188 | # When setting up new dimensions or levels, you will need to add some |
179 | 189 | # MediaWiki messages for the UI to show properly; any sysop can do this. |
— | — | @@ -213,6 +223,7 @@ |
214 | 224 | # Stable version selection and default page revision selection |
215 | 225 | # can be set per page. |
216 | 226 | $wgGroupPermissions['sysop']['stablesettings'] = true; |
| 227 | +$wgGroupPermissions['sysop']['patrolother'] = true; |
217 | 228 | |
218 | 229 | # Define when users get automatically promoted to editors. Set as false to disable. |
219 | 230 | $wgFlaggedRevsAutopromote = array( |
— | — | @@ -304,7 +315,7 @@ |
305 | 316 | * @param string $text |
306 | 317 | * @param int $id |
307 | 318 | * @return ParserOutput |
308 | | - * Get the HTML of a revision based on how it was during $timeframe |
| 319 | + * Get the HTML output of a revision based on $text |
309 | 320 | */ |
310 | 321 | public static function parseStableText( $article, $text, $id ) { |
311 | 322 | global $wgParser; |
— | — | @@ -578,7 +589,7 @@ |
579 | 590 | * Get the page cache for the top stable revision of an article |
580 | 591 | */ |
581 | 592 | public static function getPageCache( $article ) { |
582 | | - global $wgUser, $parserMemc, $wgCacheEpoch, $wgFlaggedRevsExpire; |
| 593 | + global $wgUser, $parserMemc, $wgCacheEpoch; |
583 | 594 | |
584 | 595 | wfProfileIn( __METHOD__ ); |
585 | 596 | # Make sure it is valid |
— | — | @@ -629,7 +640,7 @@ |
630 | 641 | * Updates the stable cache of a page with the given $parserOut |
631 | 642 | */ |
632 | 643 | public static function updatePageCache( $article, $parserOut=NULL ) { |
633 | | - global $wgUser, $parserMemc, $wgFlaggedRevsExpire; |
| 644 | + global $wgUser, $parserMemc, $wgParserCacheExpireTime; |
634 | 645 | # Make sure it is valid |
635 | 646 | if( is_null($parserOut) || !$article ) |
636 | 647 | return false; |
— | — | @@ -648,7 +659,7 @@ |
649 | 660 | if( $parserOut->containsOldMagic() ){ |
650 | 661 | $expire = 3600; # 1 hour |
651 | 662 | } else { |
652 | | - $expire = $wgFlaggedRevsExpire; |
| 663 | + $expire = $wgParserCacheExpireTime; |
653 | 664 | } |
654 | 665 | # Save to objectcache |
655 | 666 | $parserMemc->set( $key, $parserOut, $expire ); |
— | — | @@ -917,13 +928,21 @@ |
918 | 929 | |
919 | 930 | if( !self::isPageReviewable( $linksUpdate->mTitle ) ) |
920 | 931 | return true; |
921 | | - # Check if this page has a stable version |
922 | | - $sv = self::getStablePageRev( $linksUpdate->mTitle, true, true ); |
| 932 | + # Check if this page has a stable version by fetching it. Do not |
| 933 | + # get the fr_text field if we are to use the latest stable template revisions. |
| 934 | + global $wgUseStableTemplates; |
| 935 | + $sv = self::getStablePageRev( $linksUpdate->mTitle, !$wgUseStableTemplates, true ); |
923 | 936 | if( !$sv ) |
924 | 937 | return true; |
925 | | - # Parse the revision |
| 938 | + # Get the either the full flagged revision text or the revision text |
926 | 939 | $article = new Article( $linksUpdate->mTitle ); |
927 | | - $text = self::uncompressText( $sv->fr_text, $sv->fr_flags ); |
| 940 | + if( $wgUseStableTemplates ) { |
| 941 | + $rev = Revision::newFromId( $sv->fr_rev_id ); |
| 942 | + $text = $rev->getText(); |
| 943 | + } else { |
| 944 | + $text = self::uncompressText( $sv->fr_text, $sv->fr_flags ); |
| 945 | + } |
| 946 | + # Parse the text |
928 | 947 | $parserOut = self::parseStableText( $article, $text, $sv->fr_rev_id ); |
929 | 948 | # Might as well update the stable cache while we're at it |
930 | 949 | self::updatePageCache( $article, $parserOut ); |
— | — | @@ -975,8 +994,8 @@ |
976 | 995 | # Check for stable version of template if this feature is enabled. |
977 | 996 | # Should be in reviewable namespace, this saves unneeded DB checks as |
978 | 997 | # well as enforce site settings if they are later changed. |
979 | | - global $wgFlaggedRevsStableTemplates, $wgFlaggedRevsNamespaces; |
980 | | - if( $wgFlaggedRevsStableTemplates && in_array($title->getNamespace(), $wgFlaggedRevsNamespaces) ) { |
| 998 | + global $wgUseStableTemplates, $wgFlaggedRevsNamespaces; |
| 999 | + if( $wgUseStableTemplates && in_array($title->getNamespace(), $wgFlaggedRevsNamespaces) ) { |
981 | 1000 | $id = $dbw->selectField( 'page', 'page_ext_stable', |
982 | 1001 | array( 'page_namespace' => $title->getNamespace(), |
983 | 1002 | 'page_title' => $title->getDBkey() ), |
— | — | @@ -985,7 +1004,7 @@ |
986 | 1005 | // If there is not stable version (or that feature is not enabled), use |
987 | 1006 | // the template revision during review time. |
988 | 1007 | if( !$id ) { |
989 | | - $id = $dbw->selectField('flaggedtemplates', 'ft_tmp_rev_id', |
| 1008 | + $id = $dbw->selectField( 'flaggedtemplates', 'ft_tmp_rev_id', |
990 | 1009 | array( 'ft_rev_id' => $parser->mRevisionId, |
991 | 1010 | 'ft_namespace' => $title->getNamespace(), |
992 | 1011 | 'ft_title' => $title->getDBkey() ), |
— | — | @@ -993,9 +1012,12 @@ |
994 | 1013 | } |
995 | 1014 | |
996 | 1015 | if( !$id ) { |
| 1016 | + global $wgUseCurrentTemplates; |
| 1017 | + |
997 | 1018 | if( $id === false ) |
998 | 1019 | $parser->fr_includesMatched = false; // May want to give an error |
999 | | - $id = 0; // Zero for not found |
| 1020 | + if( !$wgUseCurrentTemplates ) |
| 1021 | + $id = 0; // Zero for not found |
1000 | 1022 | $skip = true; |
1001 | 1023 | } |
1002 | 1024 | return true; |
Index: trunk/extensions/FlaggedRevs/FlaggedArticle.php |
— | — | @@ -176,7 +176,13 @@ |
177 | 177 | $parserOut = FlaggedRevs::getPageCache( $article ); |
178 | 178 | # If no cache is available, get the text and parse it |
179 | 179 | if( $parserOut==false ) { |
180 | | - $text = FlaggedRevs::uncompressText( $tfrev->fr_text, $tfrev->fr_flags ); |
| 180 | + global $wgUseStableTemplates; |
| 181 | + if( $wgUseStableTemplates ) { |
| 182 | + $rev = Revision::newFromId( $frev->fr_rev_id ); |
| 183 | + $text = $rev->getText(); |
| 184 | + } else { |
| 185 | + $text = self::uncompressText( $frev->fr_text, $frev->fr_flags ); |
| 186 | + } |
181 | 187 | $parserOut = FlaggedRevs::parseStableText( $article, $text, $vis_id ); |
182 | 188 | # Update the general cache |
183 | 189 | FlaggedRevs::updatePageCache( $article, $parserOut ); |
Index: trunk/extensions/FlaggedRevs/FlaggedRevsPage.php |
— | — | @@ -630,11 +630,16 @@ |
631 | 631 | '<span id="mwrevisionratings" style="display:block;">' . |
632 | 632 | wfMsg('revreview-oldrating') . $wgFlaggedArticle->addTagRatings( $flags ) . |
633 | 633 | '</span>'; |
634 | | - // Parse the text... |
| 634 | + # Get the either the full flagged revision text or the revision text |
| 635 | + global $wgUseStableTemplates; |
635 | 636 | $article = new Article( $this->page ); |
636 | | - |
637 | | - $text = FlaggedRevs::uncompressText( $frev->fr_text, $frev->fr_flags ); |
638 | | - |
| 637 | + if( $wgUseStableTemplates ) { |
| 638 | + $rev = Revision::newFromId( $frev->fr_rev_id ); |
| 639 | + $text = $rev->getText(); |
| 640 | + } else { |
| 641 | + $text = self::uncompressText( $frev->fr_text, $frev->fr_flags ); |
| 642 | + } |
| 643 | + # Parse the revision text |
639 | 644 | $parserOutput = FlaggedRevs::parseStableText( $article, $text, $oldid ); |
640 | 645 | |
641 | 646 | wfRunHooks( 'OutputPageParserOutput', array( &$wgOut, $parserOutput ) ); |