Index: branches/REL1_17/phase3/includes/resourceloader/ResourceLoader.php |
— | — | @@ -66,7 +66,7 @@ |
67 | 67 | ), __METHOD__ |
68 | 68 | ); |
69 | 69 | |
70 | | - // Set modules' dependecies |
| 70 | + // Set modules' dependencies |
71 | 71 | $modulesWithDeps = array(); |
72 | 72 | foreach ( $res as $row ) { |
73 | 73 | $this->getModule( $row->md_module )->setFileDependencies( $skin, |
— | — | @@ -116,7 +116,7 @@ |
117 | 117 | * |
118 | 118 | * @param $filter String: Name of filter to run |
119 | 119 | * @param $data String: Text to filter, such as JavaScript or CSS text |
120 | | - * @return String: Filtered data |
| 120 | + * @return String: Filtered data, or a comment containing an error message |
121 | 121 | */ |
122 | 122 | protected function filter( $filter, $data ) { |
123 | 123 | wfProfileIn( __METHOD__ ); |
— | — | @@ -150,14 +150,14 @@ |
151 | 151 | $result = CSSMin::minify( $data ); |
152 | 152 | break; |
153 | 153 | } |
| 154 | + |
| 155 | + // Save filtered text to Memcached |
| 156 | + $cache->set( $key, $result ); |
154 | 157 | } catch ( Exception $exception ) { |
155 | | - throw new MWException( 'ResourceLoader filter error. ' . |
156 | | - 'Exception was thrown: ' . $exception->getMessage() ); |
| 158 | + // Return exception as a comment |
| 159 | + $result = "/*\n{$exception->__toString()}\n*/"; |
157 | 160 | } |
158 | 161 | |
159 | | - // Save filtered text to Memcached |
160 | | - $cache->set( $key, $result ); |
161 | | - |
162 | 162 | wfProfileOut( __METHOD__ ); |
163 | 163 | |
164 | 164 | return $result; |
— | — | @@ -293,6 +293,7 @@ |
294 | 294 | ob_start(); |
295 | 295 | |
296 | 296 | wfProfileIn( __METHOD__ ); |
| 297 | + $response = ''; |
297 | 298 | |
298 | 299 | // Split requested modules into two groups, modules and missing |
299 | 300 | $modules = array(); |
— | — | @@ -319,7 +320,12 @@ |
320 | 321 | } |
321 | 322 | |
322 | 323 | // Preload information needed to the mtime calculation below |
323 | | - $this->preloadModuleInfo( array_keys( $modules ), $context ); |
| 324 | + try { |
| 325 | + $this->preloadModuleInfo( array_keys( $modules ), $context ); |
| 326 | + } catch( Exception $e ) { |
| 327 | + // Add exception to the output as a comment |
| 328 | + $response .= "/*\n{$e->__toString()}\n*/"; |
| 329 | + } |
324 | 330 | |
325 | 331 | wfProfileIn( __METHOD__.'-getModifiedTime' ); |
326 | 332 | |
— | — | @@ -327,12 +333,17 @@ |
328 | 334 | // the last modified time |
329 | 335 | $mtime = wfTimestamp( TS_UNIX, $wgCacheEpoch ); |
330 | 336 | foreach ( $modules as $module ) { |
331 | | - // Bypass squid cache if the request includes any private modules |
332 | | - if ( $module->getGroup() === 'private' ) { |
333 | | - $smaxage = 0; |
| 337 | + try { |
| 338 | + // Bypass squid cache if the request includes any private modules |
| 339 | + if ( $module->getGroup() === 'private' ) { |
| 340 | + $smaxage = 0; |
| 341 | + } |
| 342 | + // Calculate maximum modified time |
| 343 | + $mtime = max( $mtime, $module->getModifiedTime( $context ) ); |
| 344 | + } catch ( Exception $e ) { |
| 345 | + // Add exception to the output as a comment |
| 346 | + $response .= "/*\n{$e->__toString()}\n*/"; |
334 | 347 | } |
335 | | - // Calculate maximum modified time |
336 | | - $mtime = max( $mtime, $module->getModifiedTime( $context ) ); |
337 | 348 | } |
338 | 349 | |
339 | 350 | wfProfileOut( __METHOD__.'-getModifiedTime' ); |
— | — | @@ -378,7 +389,7 @@ |
379 | 390 | } |
380 | 391 | |
381 | 392 | // Generate a response |
382 | | - $response = $this->makeModuleResponse( $context, $modules, $missing ); |
| 393 | + $response .= $this->makeModuleResponse( $context, $modules, $missing ); |
383 | 394 | |
384 | 395 | // Capture any PHP warnings from the output buffer and append them to the |
385 | 396 | // response in a comment if we're in debug mode. |
— | — | @@ -404,62 +415,73 @@ |
405 | 416 | public function makeModuleResponse( ResourceLoaderContext $context, |
406 | 417 | array $modules, $missing = array() ) |
407 | 418 | { |
| 419 | + $out = ''; |
408 | 420 | if ( $modules === array() && $missing === array() ) { |
409 | 421 | return '/* No modules requested. Max made me put this here */'; |
410 | 422 | } |
411 | 423 | |
412 | 424 | // Pre-fetch blobs |
413 | 425 | if ( $context->shouldIncludeMessages() ) { |
414 | | - $blobs = MessageBlobStore::get( $this, $modules, $context->getLanguage() ); |
| 426 | + //try { |
| 427 | + $blobs = MessageBlobStore::get( $this, $modules, $context->getLanguage() ); |
| 428 | + //} catch ( Exception $e ) { |
| 429 | + // Add exception to the output as a comment |
| 430 | + // $out .= "/*\n{$e->__toString()}\n*/"; |
| 431 | + //} |
415 | 432 | } else { |
416 | 433 | $blobs = array(); |
417 | 434 | } |
418 | 435 | |
419 | 436 | // Generate output |
420 | | - $out = ''; |
421 | 437 | foreach ( $modules as $name => $module ) { |
422 | | - |
423 | 438 | wfProfileIn( __METHOD__ . '-' . $name ); |
| 439 | + try { |
| 440 | + // Scripts |
| 441 | + $scripts = ''; |
| 442 | + if ( $context->shouldIncludeScripts() ) { |
| 443 | + $scripts .= $module->getScript( $context ) . "\n"; |
| 444 | + } |
424 | 445 | |
425 | | - // Scripts |
426 | | - $scripts = ''; |
427 | | - if ( $context->shouldIncludeScripts() ) { |
428 | | - $scripts .= $module->getScript( $context ) . "\n"; |
429 | | - } |
| 446 | + // Styles |
| 447 | + $styles = array(); |
| 448 | + if ( $context->shouldIncludeStyles() ) { |
| 449 | + $styles = $module->getStyles( $context ); |
| 450 | + } |
430 | 451 | |
431 | | - // Styles |
432 | | - $styles = array(); |
433 | | - if ( $context->shouldIncludeStyles() ) { |
434 | | - $styles = $module->getStyles( $context ); |
435 | | - } |
| 452 | + // Messages |
| 453 | + $messagesBlob = isset( $blobs[$name] ) ? $blobs[$name] : '{}'; |
436 | 454 | |
437 | | - // Messages |
438 | | - $messagesBlob = isset( $blobs[$name] ) ? $blobs[$name] : '{}'; |
| 455 | + // Append output |
| 456 | + switch ( $context->getOnly() ) { |
| 457 | + case 'scripts': |
| 458 | + $out .= $scripts; |
| 459 | + break; |
| 460 | + case 'styles': |
| 461 | + $out .= self::makeCombinedStyles( $styles ); |
| 462 | + break; |
| 463 | + case 'messages': |
| 464 | + $out .= self::makeMessageSetScript( new XmlJsCode( $messagesBlob ) ); |
| 465 | + break; |
| 466 | + default: |
| 467 | + // Minify CSS before embedding in mediaWiki.loader.implement call |
| 468 | + // (unless in debug mode) |
| 469 | + if ( !$context->getDebug() ) { |
| 470 | + foreach ( $styles as $media => $style ) { |
| 471 | + $styles[$media] = $this->filter( 'minify-css', $style ); |
| 472 | + } |
| 473 | + } |
| 474 | + $out .= self::makeLoaderImplementScript( $name, $scripts, $styles, |
| 475 | + new XmlJsCode( $messagesBlob ) ); |
| 476 | + break; |
| 477 | + } |
| 478 | + } catch ( Exception $e ) { |
| 479 | + // Add exception to the output as a comment |
| 480 | + $out .= "/*\n{$e->__toString()}\n*/"; |
439 | 481 | |
440 | | - // Append output |
441 | | - switch ( $context->getOnly() ) { |
442 | | - case 'scripts': |
443 | | - $out .= $scripts; |
444 | | - break; |
445 | | - case 'styles': |
446 | | - $out .= self::makeCombinedStyles( $styles ); |
447 | | - break; |
448 | | - case 'messages': |
449 | | - $out .= self::makeMessageSetScript( new XmlJsCode( $messagesBlob ) ); |
450 | | - break; |
451 | | - default: |
452 | | - // Minify CSS before embedding in mediaWiki.loader.implement call |
453 | | - // (unless in debug mode) |
454 | | - if ( !$context->getDebug() ) { |
455 | | - foreach ( $styles as $media => $style ) { |
456 | | - $styles[$media] = $this->filter( 'minify-css', $style ); |
457 | | - } |
458 | | - } |
459 | | - $out .= self::makeLoaderImplementScript( $name, $scripts, $styles, |
460 | | - new XmlJsCode( $messagesBlob ) ); |
461 | | - break; |
| 482 | + // Register module as missing |
| 483 | + $missing[] = $name; |
| 484 | + unset( $modules[$name] ); |
462 | 485 | } |
463 | | - |
464 | 486 | wfProfileOut( __METHOD__ . '-' . $name ); |
465 | 487 | } |
466 | 488 | |
Property changes on: branches/REL1_17/phase3/includes/resourceloader/ResourceLoader.php |
___________________________________________________________________ |
Modified: svn:mergeinfo |
467 | 489 | Merged /trunk/phase3/includes/resourceloader/ResourceLoader.php:r78924 |