Index: trunk/phase3/includes/ResourceLoader.php |
— | — | @@ -39,15 +39,13 @@ |
40 | 40 | protected static function initialize() { |
41 | 41 | global $IP; |
42 | 42 | |
43 | | - // Safety check - this should never be called more than once anyways |
44 | | - if ( self::$initialized ) { |
45 | | - wfDebug( 'ResourceLoader::intitialize was called more than once' ); |
46 | | - return; |
| 43 | + // Safety check - this should never be called more than once |
| 44 | + if ( !self::$initialized ) { |
| 45 | + // This needs to be first, because hooks might call ResourceLoader public interfaces which will call this |
| 46 | + self::$initialized = true; |
| 47 | + self::register( include( "$IP/resources/Resources.php" ) ); |
| 48 | + wfRunHooks( 'ResourceLoaderRegisterModules' ); |
47 | 49 | } |
48 | | - |
49 | | - self::$initialized = true; |
50 | | - self::register( include( "$IP/resources/Resources.php" ) ); |
51 | | - wfRunHooks( 'ResourceLoaderRegisterModules' ); |
52 | 50 | } |
53 | 51 | |
54 | 52 | /** |
— | — | @@ -117,9 +115,7 @@ |
118 | 116 | */ |
119 | 117 | public static function register( $name, ResourceLoaderModule $object = null ) { |
120 | 118 | |
121 | | - if ( !self::$initialized ) { |
122 | | - self::initialize(); |
123 | | - } |
| 119 | + self::initialize(); |
124 | 120 | |
125 | 121 | // Allow multiple modules to be registered in one call |
126 | 122 | if ( is_array( $name ) && !isset( $object ) ) { |
— | — | @@ -147,9 +143,7 @@ |
148 | 144 | */ |
149 | 145 | public static function getModules() { |
150 | 146 | |
151 | | - if ( !self::$initialized ) { |
152 | | - self::initialize(); |
153 | | - } |
| 147 | + self::initialize(); |
154 | 148 | |
155 | 149 | return self::$modules; |
156 | 150 | } |
— | — | @@ -162,9 +156,7 @@ |
163 | 157 | */ |
164 | 158 | public static function getModule( $name ) { |
165 | 159 | |
166 | | - if ( !self::$initialized ) { |
167 | | - self::initialize(); |
168 | | - } |
| 160 | + self::initialize(); |
169 | 161 | |
170 | 162 | return isset( self::$modules[$name] ) ? self::$modules[$name] : null; |
171 | 163 | } |
— | — | @@ -177,9 +169,7 @@ |
178 | 170 | */ |
179 | 171 | public static function getModuleRegistrations( ResourceLoaderContext $context ) { |
180 | 172 | |
181 | | - if ( !self::$initialized ) { |
182 | | - self::initialize(); |
183 | | - } |
| 173 | + self::initialize(); |
184 | 174 | |
185 | 175 | $scripts = ''; |
186 | 176 | $registrations = array(); |
— | — | @@ -215,9 +205,7 @@ |
216 | 206 | */ |
217 | 207 | public static function getHighestModifiedTime( ResourceLoaderContext $context ) { |
218 | 208 | |
219 | | - if ( !self::$initialized ) { |
220 | | - self::initialize(); |
221 | | - } |
| 209 | + self::initialize(); |
222 | 210 | |
223 | 211 | $time = 1; // wfTimestamp() treats 0 as 'now', so that's not a suitable choice |
224 | 212 | |
— | — | @@ -237,9 +225,7 @@ |
238 | 226 | global $wgResourceLoaderVersionedClientMaxage, $wgResourceLoaderVersionedServerMaxage; |
239 | 227 | global $wgResourceLoaderUnversionedServerMaxage, $wgResourceLoaderUnversionedClientMaxage; |
240 | 228 | |
241 | | - if ( !self::$initialized ) { |
242 | | - self::initialize(); |
243 | | - } |
| 229 | + self::initialize(); |
244 | 230 | |
245 | 231 | // Split requested modules into two groups, modules and missing |
246 | 232 | $modules = array(); |