r28332 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r28331‎ | r28332 | r28333 >
Date:01:39, 10 December 2007
Author:aaron
Status:old
Tags:
Comment:
*Finish up $wgUseStableTemplates
*Remove unneeded expire variable
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
@@ -10,6 +10,7 @@
1111 define('FLAGGED_CSS', $wgScriptPath.'/extensions/FlaggedRevs/flaggedrevs.css' );
1212 if( !defined( 'FLAGGED_JS' ) )
1313 define('FLAGGED_JS', $wgScriptPath.'/extensions/FlaggedRevs/flaggedrevs.js' );
 14+
1415 if( !defined( 'FLAGGED_VIS_NORMAL' ) )
1516 define('FLAGGED_VIS_NORMAL',0);
1617 if( !defined( 'FLAGGED_VIS_LATEST' ) )
@@ -166,13 +167,22 @@
167168 # Auto-review new pages with the minimal level?
168169 $wgFlaggedRevsAutoReviewNew = false;
169170
170 -# How long to cache stable versions? (seconds)
171 -$wgFlaggedRevsExpire = 7 * 24 * 3600;
172171 # Compress pre-processed flagged revision text?
173172 $wgFlaggedRevsCompression = false;
174173
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;
177187
178188 # When setting up new dimensions or levels, you will need to add some
179189 # MediaWiki messages for the UI to show properly; any sysop can do this.
@@ -213,6 +223,7 @@
214224 # Stable version selection and default page revision selection
215225 # can be set per page.
216226 $wgGroupPermissions['sysop']['stablesettings'] = true;
 227+$wgGroupPermissions['sysop']['patrolother'] = true;
217228
218229 # Define when users get automatically promoted to editors. Set as false to disable.
219230 $wgFlaggedRevsAutopromote = array(
@@ -304,7 +315,7 @@
305316 * @param string $text
306317 * @param int $id
307318 * @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
309320 */
310321 public static function parseStableText( $article, $text, $id ) {
311322 global $wgParser;
@@ -578,7 +589,7 @@
579590 * Get the page cache for the top stable revision of an article
580591 */
581592 public static function getPageCache( $article ) {
582 - global $wgUser, $parserMemc, $wgCacheEpoch, $wgFlaggedRevsExpire;
 593+ global $wgUser, $parserMemc, $wgCacheEpoch;
583594
584595 wfProfileIn( __METHOD__ );
585596 # Make sure it is valid
@@ -629,7 +640,7 @@
630641 * Updates the stable cache of a page with the given $parserOut
631642 */
632643 public static function updatePageCache( $article, $parserOut=NULL ) {
633 - global $wgUser, $parserMemc, $wgFlaggedRevsExpire;
 644+ global $wgUser, $parserMemc, $wgParserCacheExpireTime;
634645 # Make sure it is valid
635646 if( is_null($parserOut) || !$article )
636647 return false;
@@ -648,7 +659,7 @@
649660 if( $parserOut->containsOldMagic() ){
650661 $expire = 3600; # 1 hour
651662 } else {
652 - $expire = $wgFlaggedRevsExpire;
 663+ $expire = $wgParserCacheExpireTime;
653664 }
654665 # Save to objectcache
655666 $parserMemc->set( $key, $parserOut, $expire );
@@ -917,13 +928,21 @@
918929
919930 if( !self::isPageReviewable( $linksUpdate->mTitle ) )
920931 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 );
923936 if( !$sv )
924937 return true;
925 - # Parse the revision
 938+ # Get the either the full flagged revision text or the revision text
926939 $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
928947 $parserOut = self::parseStableText( $article, $text, $sv->fr_rev_id );
929948 # Might as well update the stable cache while we're at it
930949 self::updatePageCache( $article, $parserOut );
@@ -975,8 +994,8 @@
976995 # Check for stable version of template if this feature is enabled.
977996 # Should be in reviewable namespace, this saves unneeded DB checks as
978997 # 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) ) {
9811000 $id = $dbw->selectField( 'page', 'page_ext_stable',
9821001 array( 'page_namespace' => $title->getNamespace(),
9831002 'page_title' => $title->getDBkey() ),
@@ -985,7 +1004,7 @@
9861005 // If there is not stable version (or that feature is not enabled), use
9871006 // the template revision during review time.
9881007 if( !$id ) {
989 - $id = $dbw->selectField('flaggedtemplates', 'ft_tmp_rev_id',
 1008+ $id = $dbw->selectField( 'flaggedtemplates', 'ft_tmp_rev_id',
9901009 array( 'ft_rev_id' => $parser->mRevisionId,
9911010 'ft_namespace' => $title->getNamespace(),
9921011 'ft_title' => $title->getDBkey() ),
@@ -993,9 +1012,12 @@
9941013 }
9951014
9961015 if( !$id ) {
 1016+ global $wgUseCurrentTemplates;
 1017+
9971018 if( $id === false )
9981019 $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
10001022 $skip = true;
10011023 }
10021024 return true;
Index: trunk/extensions/FlaggedRevs/FlaggedArticle.php
@@ -176,7 +176,13 @@
177177 $parserOut = FlaggedRevs::getPageCache( $article );
178178 # If no cache is available, get the text and parse it
179179 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+ }
181187 $parserOut = FlaggedRevs::parseStableText( $article, $text, $vis_id );
182188 # Update the general cache
183189 FlaggedRevs::updatePageCache( $article, $parserOut );
Index: trunk/extensions/FlaggedRevs/FlaggedRevsPage.php
@@ -630,11 +630,16 @@
631631 '<span id="mwrevisionratings" style="display:block;">' .
632632 wfMsg('revreview-oldrating') . $wgFlaggedArticle->addTagRatings( $flags ) .
633633 '</span>';
634 - // Parse the text...
 634+ # Get the either the full flagged revision text or the revision text
 635+ global $wgUseStableTemplates;
635636 $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
639644 $parserOutput = FlaggedRevs::parseStableText( $article, $text, $oldid );
640645
641646 wfRunHooks( 'OutputPageParserOutput', array( &$wgOut, $parserOutput ) );

Status & tagging log