Index: trunk/extensions/FlaggedRevs/FlaggedRevs.php |
— | — | @@ -189,13 +189,10 @@ |
190 | 190 | FlaggedRevsUISetup::defineLogBasicDescription( $wgLogNames, $wgLogHeaders, $wgFilterLogTypes ); |
191 | 191 | FlaggedRevsUISetup::defineLogActionHanders( $wgLogActions, $wgLogActionsHandlers ); |
192 | 192 | |
193 | | -# Actually register special pages |
194 | | -FlaggedRevsUISetup::defineSpecialPages( $wgSpecialPages, $wgSpecialPageGroups ); |
195 | | - |
196 | 193 | # JS/CSS modules and message bundles used by JS scripts |
197 | 194 | FlaggedRevsUISetup::defineResourceModules( $wgResourceModules ); |
198 | 195 | |
199 | | -# ####### EVENT-HANDLER FUNCTIONS ######### |
| 196 | +# ####### HOOK CALLBACK FUNCTIONS ######### |
200 | 197 | |
201 | 198 | # ######## API ######## |
202 | 199 | # Add flagging data to ApiQueryRevisions |
— | — | @@ -273,13 +270,18 @@ |
274 | 271 | $wgHooks['UserGetRights'][] = 'FlaggedRevsHooks::onUserGetRights'; |
275 | 272 | } |
276 | 273 | |
277 | | -# ####### END HOOK TRIGGERED FUNCTIONS ######### |
| 274 | +# ####### END HOOK CALLBACK FUNCTIONS ######### |
278 | 275 | |
279 | 276 | // Note: avoid calls to FlaggedRevs class here for performance |
280 | 277 | function efLoadFlaggedRevs() { |
| 278 | + # LocalSettings.php loaded, safe to load config |
| 279 | + FlaggedRevs::ready(); |
| 280 | + |
281 | 281 | # Conditional autopromote groups |
282 | 282 | efSetFlaggedRevsAutopromoteConfig(); |
283 | 283 | |
| 284 | + # Register special pages (some are conditional) |
| 285 | + efSetFlaggedRevsSpecialPages(); |
284 | 286 | # Conditional API modules |
285 | 287 | efSetFlaggedRevsConditionalAPIModules(); |
286 | 288 | # Load hooks that aren't always set |
— | — | @@ -356,6 +358,11 @@ |
357 | 359 | } |
358 | 360 | } |
359 | 361 | |
| 362 | +function efSetFlaggedRevsSpecialPages() { |
| 363 | + global $wgSpecialPages, $wgSpecialPageGroups; |
| 364 | + FlaggedRevsUISetup::defineSpecialPages( $wgSpecialPages, $wgSpecialPageGroups ); |
| 365 | +} |
| 366 | + |
360 | 367 | function efSetFlaggedRevsConditionalRights() { |
361 | 368 | global $wgGroupPermissions, $wgFlaggedRevsProtection; |
362 | 369 | if ( $wgFlaggedRevsProtection ) { |
Index: trunk/extensions/FlaggedRevs/dataclasses/FlaggedRevs.class.php |
— | — | @@ -21,13 +21,24 @@ |
22 | 22 | # Autoreview config |
23 | 23 | protected static $autoReviewConfig = 0; |
24 | 24 | |
| 25 | + protected static $canLoad = false; |
25 | 26 | protected static $loaded = false; |
26 | 27 | |
27 | | - public static function load() { |
| 28 | + /** |
| 29 | + * Signal that LocalSettings.php is loaded |
| 30 | + */ |
| 31 | + public static function ready() { |
| 32 | + self::$canLoad = true; |
| 33 | + } |
| 34 | + |
| 35 | + protected static function load() { |
28 | 36 | global $wgFlaggedRevsTags, $wgFlaggedRevTags; |
29 | 37 | if ( self::$loaded ) { |
30 | 38 | return true; |
31 | 39 | } |
| 40 | + if ( !self::$canLoad ) { // sanity |
| 41 | + wfDebugDieBacktrace( 'FlaggedRevs config loaded too soon! Possibly before LocalSettings.php!' ); |
| 42 | + } |
32 | 43 | self::$loaded = true; |
33 | 44 | $flaggedRevsTags = null; |
34 | 45 | if ( isset( $wgFlaggedRevTags ) ) { |
— | — | @@ -46,7 +57,7 @@ |
47 | 58 | # Sanity checks |
48 | 59 | $safeTag = htmlspecialchars( $tag ); |
49 | 60 | if ( !preg_match( '/^[a-zA-Z]{1,20}$/', $tag ) || $safeTag !== $tag ) { |
50 | | - throw new MWException( 'FlaggedRevs given invalid tag name!' ); |
| 61 | + die( 'FlaggedRevs given invalid tag name!' ); |
51 | 62 | } |
52 | 63 | # Define "quality" and "pristine" reqs |
53 | 64 | if ( is_array( $levels ) ) { |
— | — | @@ -73,7 +84,7 @@ |
74 | 85 | } |
75 | 86 | # Sanity checks |
76 | 87 | if ( !is_integer( $minQL ) || !is_integer( $minPL ) ) { |
77 | | - throw new MWException( 'FlaggedRevs given invalid tag value!' ); |
| 88 | + die( 'FlaggedRevs given invalid tag value!' ); |
78 | 89 | } |
79 | 90 | if ( $minQL > $ratingLevels ) { |
80 | 91 | self::$qualityVersions = false; |
— | — | @@ -101,9 +112,9 @@ |
102 | 113 | global $wgFlaggedRevsNamespaces, $wgFlaggedRevsPatrolNamespaces; |
103 | 114 | foreach ( $wgFlaggedRevsNamespaces as $ns ) { |
104 | 115 | if ( MWNamespace::isTalk( $ns ) ) { |
105 | | - throw new MWException( 'FlaggedRevs given talk namespace in $wgFlaggedRevsNamespaces!' ); |
| 116 | + die( 'FlaggedRevs given talk namespace in $wgFlaggedRevsNamespaces!' ); |
106 | 117 | } elseif ( $ns == NS_MEDIAWIKI ) { |
107 | | - throw new MWException( 'FlaggedRevs given NS_MEDIAWIKI in $wgFlaggedRevsNamespaces!' ); |
| 118 | + die( 'FlaggedRevs given NS_MEDIAWIKI in $wgFlaggedRevsNamespaces!' ); |
108 | 119 | } |
109 | 120 | } |
110 | 121 | self::$reviewNamespaces = $wgFlaggedRevsNamespaces; |
Index: trunk/extensions/FlaggedRevs/presentation/FlaggedRevsUI.setup.php |
— | — | @@ -1,6 +1,8 @@ |
2 | 2 | <?php |
3 | 3 | /** |
4 | | - * Class containing hooked functions for a FlaggedRevs environment |
| 4 | + * Class containing UI setup functions for a FlaggedRevs environment. |
| 5 | + * This depends on config variables in LocalSettings.php. |
| 6 | + * Note: avoid FlaggedRevs class calls here for performance (like load.php). |
5 | 7 | */ |
6 | 8 | class FlaggedRevsUISetup { |
7 | 9 | /** |
— | — | @@ -89,9 +91,10 @@ |
90 | 92 | * @return void |
91 | 93 | */ |
92 | 94 | public static function defineSpecialPages( array &$pages, array &$groups ) { |
93 | | - global $wgUseTagFilter; |
| 95 | + global $wgFlaggedRevsProtection, $wgFlaggedRevsNamespaces, $wgUseTagFilter; |
| 96 | + |
94 | 97 | // Show special pages only if FlaggedRevs is enabled on some namespaces |
95 | | - if ( FlaggedRevs::getReviewNamespaces() ) { |
| 98 | + if ( count( $wgFlaggedRevsNamespaces ) ) { |
96 | 99 | $pages['RevisionReview'] = 'RevisionReview'; // unlisted |
97 | 100 | $pages['ReviewedVersions'] = 'ReviewedVersions'; // unlisted |
98 | 101 | $pages['PendingChanges'] = 'PendingChanges'; |
— | — | @@ -101,7 +104,7 @@ |
102 | 105 | $pages['ProblemChanges'] = 'ProblemChanges'; |
103 | 106 | $groups['ProblemChanges'] = 'quality'; |
104 | 107 | } |
105 | | - if ( !FlaggedRevs::useOnlyIfProtected() ) { |
| 108 | + if ( !$wgFlaggedRevsProtection ) { |
106 | 109 | $pages['ReviewedPages'] = 'ReviewedPages'; |
107 | 110 | $groups['ReviewedPages'] = 'quality'; |
108 | 111 | $pages['UnreviewedPages'] = 'UnreviewedPages'; |
— | — | @@ -112,7 +115,7 @@ |
113 | 116 | $pages['ValidationStatistics'] = 'ValidationStatistics'; |
114 | 117 | $groups['ValidationStatistics'] = 'quality'; |
115 | 118 | // Protect levels define allowed stability settings |
116 | | - if ( FlaggedRevs::useProtectionLevels() ) { |
| 119 | + if ( $wgFlaggedRevsProtection ) { |
117 | 120 | $pages['StablePages'] = 'StablePages'; |
118 | 121 | $groups['StablePages'] = 'quality'; |
119 | 122 | } else { |