r79891 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r79890‎ | r79891 | r79892 >
Date:12:29, 9 January 2011
Author:catrope
Status:ok
Tags:
Comment:
Followup r78924: keep track of exception/warning comments separately, to prevent them from being eaten by the minifier. This also prevents filter cache pollution. Additionally, uncomment some wrongfully commented-out code introduced in r78924, and add newlines after exception/warning comments
Modified paths:
  • /trunk/phase3/includes/resourceloader/ResourceLoader.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/resourceloader/ResourceLoader.php
@@ -155,7 +155,7 @@
156156 $cache->set( $key, $result );
157157 } catch ( Exception $exception ) {
158158 // Return exception as a comment
159 - $result = "/*\n{$exception->__toString()}\n*/";
 159+ $result = "/*\n{$exception->__toString()}\n*/\n";
160160 }
161161
162162 wfProfileOut( __METHOD__ );
@@ -293,7 +293,7 @@
294294 ob_start();
295295
296296 wfProfileIn( __METHOD__ );
297 - $response = '';
 297+ $exceptions = '';
298298
299299 // Split requested modules into two groups, modules and missing
300300 $modules = array();
@@ -324,7 +324,7 @@
325325 $this->preloadModuleInfo( array_keys( $modules ), $context );
326326 } catch( Exception $e ) {
327327 // Add exception to the output as a comment
328 - $response .= "/*\n{$e->__toString()}\n*/";
 328+ $exceptions .= "/*\n{$e->__toString()}\n*/\n";
329329 }
330330
331331 wfProfileIn( __METHOD__.'-getModifiedTime' );
@@ -342,7 +342,7 @@
343343 $mtime = max( $mtime, $module->getModifiedTime( $context ) );
344344 } catch ( Exception $e ) {
345345 // Add exception to the output as a comment
346 - $response .= "/*\n{$e->__toString()}\n*/";
 346+ $exceptions .= "/*\n{$e->__toString()}\n*/\n";
347347 }
348348 }
349349
@@ -393,12 +393,15 @@
394394 }
395395
396396 // Generate a response
397 - $response .= $this->makeModuleResponse( $context, $modules, $missing );
 397+ $response = $this->makeModuleResponse( $context, $modules, $missing );
 398+
 399+ // Prepend comments indicating exceptions
 400+ $response = $exceptions . $response;
398401
399402 // Capture any PHP warnings from the output buffer and append them to the
400403 // response in a comment if we're in debug mode.
401404 if ( $context->getDebug() && strlen( $warnings = ob_get_contents() ) ) {
402 - $response .= "/*\n$warnings\n*/";
 405+ $response = "/*\n$warnings\n*/\n" . $response;
403406 }
404407
405408 // Remove the output buffer and output the response
@@ -420,18 +423,19 @@
421424 array $modules, $missing = array() )
422425 {
423426 $out = '';
 427+ $exceptions = '';
424428 if ( $modules === array() && $missing === array() ) {
425429 return '/* No modules requested. Max made me put this here */';
426430 }
427431
428432 // Pre-fetch blobs
429433 if ( $context->shouldIncludeMessages() ) {
430 - //try {
 434+ try {
431435 $blobs = MessageBlobStore::get( $this, $modules, $context->getLanguage() );
432 - //} catch ( Exception $e ) {
 436+ } catch ( Exception $e ) {
433437 // Add exception to the output as a comment
434 - // $out .= "/*\n{$e->__toString()}\n*/";
435 - //}
 438+ $exceptions .= "/*\n{$e->__toString()}\n*/\n";
 439+ }
436440 } else {
437441 $blobs = array();
438442 }
@@ -480,7 +484,7 @@
481485 }
482486 } catch ( Exception $e ) {
483487 // Add exception to the output as a comment
484 - $out .= "/*\n{$e->__toString()}\n*/";
 488+ $exceptions .= "/*\n{$e->__toString()}\n*/\n";
485489
486490 // Register module as missing
487491 $missing[] = $name;
@@ -505,12 +509,12 @@
506510 }
507511
508512 if ( $context->getDebug() ) {
509 - return $out;
 513+ return $exceptions . $out;
510514 } else {
511515 if ( $context->getOnly() === 'styles' ) {
512 - return $this->filter( 'minify-css', $out );
 516+ return $exceptions . $this->filter( 'minify-css', $out );
513517 } else {
514 - return $this->filter( 'minify-js', $out );
 518+ return $exceptions . $this->filter( 'minify-js', $out );
515519 }
516520 }
517521 }

Follow-up revisions

RevisionCommit summaryAuthorDate
r805261.17: MFT r78232, r78253, r79722, r79732, r79785, r79817, r79864, r79891, r79...catrope22:19, 18 January 2011

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r78924Proper exception handling in ResourceLoader. Catch exceptions and output them...catrope20:14, 23 December 2010

Status & tagging log