r37414 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r37413‎ | r37414 | r37415 >
Date:17:21, 9 July 2008
Author:aaron
Status:old
Tags:
Comment:
* Make this work with filecache properly
* Generalize the page exemption ability
Modified paths:
  • /trunk/extensions/FlaggedRevs/FlaggedArticle.php (modified) (history)
  • /trunk/extensions/FlaggedRevs/FlaggedRevs.class.php (modified) (history)
  • /trunk/extensions/FlaggedRevs/FlaggedRevs.php (modified) (history)

Diff [purge]

Index: trunk/extensions/FlaggedRevs/FlaggedRevs.php
@@ -45,6 +45,10 @@
4646 # Patrollable namespaces
4747 $wgFlaggedRevsPatrolNamespaces = array( NS_CATEGORY, NS_IMAGE, NS_TEMPLATE );
4848
 49+# Pages exempt from reviewing
 50+$wgFlaggedRevsWhitelist = array();
 51+# $wgFlaggedRevsWhitelist = array( 'Main_Page' );
 52+
4953 # Do flagged revs override the default view?
5054 $wgFlaggedRevsOverride = true;
5155 # Do quality revisions show instead of sighted if present by default?
@@ -343,6 +347,9 @@
344348 # Set aliases
345349 $wgHooks['LanguageGetSpecialPageAliases'][] = 'FlaggedRevs::addLocalizedSpecialPageNames';
346350
 351+# File cache
 352+$wgHooks['IsFileCacheable'][] = 'FlaggedRevs::isFileCacheable';
 353+
347354 # Duplicate flagged* tables in parserTests.php
348355 $wgHooks['ParserTestTables'][] = 'FlaggedRevs::onParserTestTables';
349356
Index: trunk/extensions/FlaggedRevs/FlaggedArticle.php
@@ -401,7 +401,7 @@
402402 # Add revision notes
403403 $wgOut->mBodytext = $wgOut->mBodytext . $notes;
404404 // Add "no reviewed version" tag, but not for main page or printable output.
405 - } else if( !$wgOut->isPrintable() && !FlaggedRevs::isMainPage( $this->parent->getTitle() ) ) {
 405+ } else if( !$wgOut->isPrintable() ) {
406406 // Simple icon-based UI
407407 if( FlaggedRevs::useSimpleUI() ) {
408408 $msg = $old ? 'revreview-quick-invalid' : 'revreview-quick-none';
Index: trunk/extensions/FlaggedRevs/FlaggedRevs.class.php
@@ -147,6 +147,15 @@
148148 return empty(self::$dimensions);
149149 }
150150
 151+ /**
 152+ * Do anons see the stable version by default?
 153+ * @returns bool
 154+ */
 155+ public static function publicViewStableByDefault() {
 156+ global $wgFlaggedRevsOverride, $wgFlaggedRevsExceptions;
 157+ return ($wgFlaggedRevsOverride && !in_array('*',$wgFlaggedRevsExceptions) );
 158+ }
 159+
151160 ################# Parsing functions #################
152161
153162 /**
@@ -699,14 +708,6 @@
700709 ################# Other utility functions #################
701710
702711 /**
703 - * @param Title $title
704 - * @return bool, is $title the main page?
705 - */
706 - public static function isMainPage( $title ) {
707 - return $title->equals( Title::newMainPage() );
708 - }
709 -
710 - /**
711712 * @param Array $flags
712713 * @return bool, is this revision at quality condition?
713714 */
@@ -748,9 +749,14 @@
749750 * @return bool
750751 */
751752 public static function isPageReviewable( $title ) {
752 - global $wgFlaggedRevsNamespaces;
 753+ global $wgFlaggedRevsNamespaces, $wgFlaggedRevsWhitelist;
753754 # FIXME: Treat NS_MEDIA as NS_IMAGE
754755 $ns = ( $title->getNamespace() == NS_MEDIA ) ? NS_IMAGE : $title->getNamespace();
 756+ # Check whitelist for exempt pages
 757+ var_dump( $title->getPrefixedDBKey() );
 758+ if( in_array( $title->getPrefixedDBKey(), $wgFlaggedRevsWhitelist ) ) {
 759+ return false;
 760+ }
755761 return ( in_array($ns,$wgFlaggedRevsNamespaces) && !$title->isTalkPage() && $ns != NS_MEDIAWIKI );
756762 }
757763
@@ -2112,6 +2118,19 @@
21132119 }
21142120 return true;
21152121 }
 2122+
 2123+ public static function isFileCacheable( $article ) {
 2124+ $fa = FlaggedArticle::getInstance( $article );
 2125+ # If the stable is the default, and we are viewing it...cache it!
 2126+ if( self::publicViewStableByDefault() ) {
 2127+ return ( $fa->pageOverride() && $fa->getStableRev( true ) );
 2128+ # If the draft is the default, and we are viewing it...cache it!
 2129+ } else {
 2130+ global $wgRequest;
 2131+ # We don't want to cache the pending edit notice though
 2132+ return !( $fa->pageOverride() && $fa->getStableRev( true ) ) && !$wgRequest->getVal('shownotice');
 2133+ }
 2134+ }
21162135
21172136 public static function onParserTestTables( &$tables ) {
21182137 $tables[] = 'flaggedpages';

Status & tagging log