r102621 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r102620‎ | r102621 | r102622 >
Date:03:49, 10 November 2011
Author:aaron
Status:ok
Tags:
Comment:
* Moved setting of $wgAjaxExportList to FlaggedRevsUISetup::defineAjaxFunctions().
* Moved setting of $wgSpecialPageUpdates to FlaggedRevsUISetup::defineSpecialPages(). We don't want to have ab UnreviewedPages query every time updateSpecialPages is run if aren't even using it (and it's also more expensive in the case where $wgFlaggedRevsProtection is on).
* Moved FlaggedRevs::ready() function to FlaggedRevsSetup to avoid including the FlaggedRevs class on each request.
Modified paths:
  • /trunk/extensions/FlaggedRevs/FlaggedRevs.php (modified) (history)
  • /trunk/extensions/FlaggedRevs/FlaggedRevs.setup.php (modified) (history)
  • /trunk/extensions/FlaggedRevs/dataclasses/FlaggedRevs.class.php (modified) (history)
  • /trunk/extensions/FlaggedRevs/presentation/FlaggedRevsUI.setup.php (modified) (history)

Diff [purge]

Index: trunk/extensions/FlaggedRevs/presentation/FlaggedRevsUI.setup.php
@@ -88,9 +88,10 @@
8989 * Register FlaggedRevs special pages as needed.
9090 * @param $pages Array $wgSpecialPages (list of special pages)
9191 * @param $groups Array $wgSpecialPageGroups (assoc array of special page groups)
 92+ * @param $updates Array $wgSpecialPageCacheUpdates (assoc array of special page updaters)
9293 * @return void
9394 */
94 - public static function defineSpecialPages( array &$pages, array &$groups ) {
 95+ public static function defineSpecialPages( array &$pages, array &$groups, array &$updates ) {
9596 global $wgFlaggedRevsProtection, $wgFlaggedRevsNamespaces, $wgUseTagFilter;
9697
9798 // Show special pages only if FlaggedRevs is enabled on some namespaces
@@ -109,11 +110,13 @@
110111 $groups['ReviewedPages'] = 'quality';
111112 $pages['UnreviewedPages'] = 'UnreviewedPages';
112113 $groups['UnreviewedPages'] = 'quality';
 114+ $updates['UnreviewedPages'] = 'UnreviewedPages::updateQueryCache';
113115 }
114116 $pages['QualityOversight'] = 'QualityOversight';
115117 $groups['QualityOversight'] = 'quality';
116118 $pages['ValidationStatistics'] = 'ValidationStatistics';
117119 $groups['ValidationStatistics'] = 'quality';
 120+ $updates['ValidationStatistics'] = 'FlaggedRevsStats::updateCache';
118121 // Protect levels define allowed stability settings
119122 if ( $wgFlaggedRevsProtection ) {
120123 $pages['StablePages'] = 'StablePages';
@@ -171,6 +174,16 @@
172175 }
173176
174177 /**
 178+ * Define AJAX dispatcher functions
 179+ * @param $ajaxExportList Array $wgAjaxExportList
 180+ * @return void
 181+ */
 182+ public static function defineAjaxFunctions( &$ajaxExportList ) {
 183+ $ajaxExportList[] = 'RevisionReview::AjaxReview';
 184+ $ajaxExportList[] = 'FlaggablePageView::AjaxBuildDiffHeaderItems';
 185+ }
 186+
 187+ /**
175188 * Append FlaggedRevs log names and set filterable logs
176189 * @param $logNames Array $wgLogNames (assoc array of log name message keys)
177190 * @param $logHeaders Array $wgLogHeaders (assoc array of log header message keys)
Index: trunk/extensions/FlaggedRevs/FlaggedRevs.setup.php
@@ -5,7 +5,24 @@
66 * Note: avoid FlaggedRevs class calls here for performance (like load.php).
77 */
88 class FlaggedRevsSetup {
 9+ protected static $canLoad = false;
 10+
911 /**
 12+ * Signal that LocalSettings.php is loaded.
 13+ */
 14+ public static function setReady() {
 15+ self::$canLoad = true;
 16+ }
 17+
 18+ /*
 19+ * The FlaggedRevs class uses this as a sanity check.
 20+ * @return bool
 21+ */
 22+ public static function isReady() {
 23+ return self::$canLoad;
 24+ }
 25+
 26+ /**
1027 * Register FlaggedRevs source code paths.
1128 * This function must NOT depend on any config vars.
1229 *
@@ -289,13 +306,14 @@
290307 }
291308
292309 /**
293 - * Set $wgSpecialPages and $wgSpecialPageGroups
 310+ * Set special pages
294311 *
295312 * @return void
296313 */
297314 public static function setSpecialPages() {
298 - global $wgSpecialPages, $wgSpecialPageGroups;
299 - FlaggedRevsUISetup::defineSpecialPages( $wgSpecialPages, $wgSpecialPageGroups );
 315+ global $wgSpecialPages, $wgSpecialPageGroups, $wgSpecialPageCacheUpdates;
 316+ FlaggedRevsUISetup::defineSpecialPages(
 317+ $wgSpecialPages, $wgSpecialPageGroups, $wgSpecialPageCacheUpdates );
300318 }
301319
302320 /**
Index: trunk/extensions/FlaggedRevs/FlaggedRevs.php
@@ -90,6 +90,9 @@
9191 # JS/CSS modules and message bundles used by JS scripts
9292 FlaggedRevsUISetup::defineResourceModules( $wgResourceModules );
9393
 94+# AJAX functions
 95+FlaggedRevsUISetup::defineAjaxFunctions( $wgAjaxExportList );
 96+
9497 # Load the extension after setup is finished
9598 $wgExtensionFunctions[] = 'efLoadFlaggedRevs';
9699
@@ -100,7 +103,7 @@
101104 */
102105 function efLoadFlaggedRevs() {
103106 # LocalSettings.php loaded, safe to load config
104 - FlaggedRevs::ready();
 107+ FlaggedRevsSetup::setReady();
105108
106109 # Conditional autopromote groups
107110 FlaggedRevsSetup::setAutopromoteConfig();
@@ -117,13 +120,5 @@
118121 FlaggedRevsSetup::setConditionalPreferences();
119122 }
120123
121 -# AJAX functions
122 -$wgAjaxExportList[] = 'RevisionReview::AjaxReview';
123 -$wgAjaxExportList[] = 'FlaggablePageView::AjaxBuildDiffHeaderItems';
124 -
125 -# Cache update
126 -$wgSpecialPageCacheUpdates['UnreviewedPages'] = 'UnreviewedPages::updateQueryCache';
127 -$wgSpecialPageCacheUpdates['ValidationStatistics'] = 'FlaggedRevsStats::updateCache';
128 -
129124 # B/C ...
130125 $wgLogActions['rights/erevoke'] = 'rights-editor-revoke';
Index: trunk/extensions/FlaggedRevs/dataclasses/FlaggedRevs.class.php
@@ -21,22 +21,14 @@
2222 # Autoreview config
2323 protected static $autoReviewConfig = 0;
2424
25 - protected static $canLoad = false;
2625 protected static $loaded = false;
2726
28 - /**
29 - * Signal that LocalSettings.php is loaded
30 - */
31 - public static function ready() {
32 - self::$canLoad = true;
33 - }
34 -
3527 protected static function load() {
3628 global $wgFlaggedRevsTags, $wgFlaggedRevTags;
3729 if ( self::$loaded ) {
3830 return true;
3931 }
40 - if ( !self::$canLoad ) { // sanity
 32+ if ( !FlaggedRevsSetup::isReady() ) { // sanity
4133 wfDebugDieBacktrace( 'FlaggedRevs config loaded too soon! Possibly before LocalSettings.php!' );
4234 }
4335 self::$loaded = true;

Status & tagging log