Index: branches/wmf/1.18wmf1/includes/resourceloader/ResourceLoader.php |
— | — | @@ -208,43 +208,38 @@ |
209 | 209 | wfProfileIn( __METHOD__ ); |
210 | 210 | |
211 | 211 | // Allow multiple modules to be registered in one call |
212 | | - if ( is_array( $name ) ) { |
213 | | - foreach ( $name as $key => $value ) { |
214 | | - $this->register( $key, $value ); |
| 212 | + $registrations = is_array( $name ) ? $name : array( $name => $info ); |
| 213 | + foreach ( $registrations as $name => $info ) { |
| 214 | + // Disallow duplicate registrations |
| 215 | + if ( isset( $this->moduleInfos[$name] ) ) { |
| 216 | + // A module has already been registered by this name |
| 217 | + throw new MWException( |
| 218 | + 'ResourceLoader duplicate registration error. ' . |
| 219 | + 'Another module has already been registered as ' . $name |
| 220 | + ); |
215 | 221 | } |
216 | | - wfProfileOut( __METHOD__ ); |
217 | | - return; |
218 | | - } |
219 | 222 | |
220 | | - // Disallow duplicate registrations |
221 | | - if ( isset( $this->moduleInfos[$name] ) ) { |
222 | | - // A module has already been registered by this name |
223 | | - throw new MWException( |
224 | | - 'ResourceLoader duplicate registration error. ' . |
225 | | - 'Another module has already been registered as ' . $name |
226 | | - ); |
227 | | - } |
| 223 | + // Check $name for illegal characters |
| 224 | + if ( preg_match( '/[|,!]/', $name ) ) { |
| 225 | + throw new MWException( "ResourceLoader module name '$name' is invalid. Names may not contain pipes (|), commas (,) or exclamation marks (!)" ); |
| 226 | + } |
228 | 227 | |
229 | | - // Check $name for illegal characters |
230 | | - if ( preg_match( '/[|,!]/', $name ) ) { |
231 | | - throw new MWException( "ResourceLoader module name '$name' is invalid. Names may not contain pipes (|), commas (,) or exclamation marks (!)" ); |
232 | | - } |
| 228 | + // Attach module |
| 229 | + if ( is_object( $info ) ) { |
| 230 | + // Old calling convention |
| 231 | + // Validate the input |
| 232 | + if ( !( $info instanceof ResourceLoaderModule ) ) { |
| 233 | + throw new MWException( 'ResourceLoader invalid module error. ' . |
| 234 | + 'Instances of ResourceLoaderModule expected.' ); |
| 235 | + } |
233 | 236 | |
234 | | - // Attach module |
235 | | - if ( is_object( $info ) ) { |
236 | | - // Old calling convention |
237 | | - // Validate the input |
238 | | - if ( !( $info instanceof ResourceLoaderModule ) ) { |
239 | | - throw new MWException( 'ResourceLoader invalid module error. ' . |
240 | | - 'Instances of ResourceLoaderModule expected.' ); |
| 237 | + $this->moduleInfos[$name] = array( 'object' => $info ); |
| 238 | + $info->setName( $name ); |
| 239 | + $this->modules[$name] = $info; |
| 240 | + } else { |
| 241 | + // New calling convention |
| 242 | + $this->moduleInfos[$name] = $info; |
241 | 243 | } |
242 | | - |
243 | | - $this->moduleInfos[$name] = array( 'object' => $info ); |
244 | | - $info->setName( $name ); |
245 | | - $this->modules[$name] = $info; |
246 | | - } else { |
247 | | - // New calling convention |
248 | | - $this->moduleInfos[$name] = $info; |
249 | 244 | } |
250 | 245 | |
251 | 246 | wfProfileOut( __METHOD__ ); |
Property changes on: branches/wmf/1.18wmf1/includes/resourceloader/ResourceLoader.php |
___________________________________________________________________ |
Modified: svn:mergeinfo |
252 | 247 | Merged /trunk/phase3/includes/resourceloader/ResourceLoader.php:r103682 |