From 91e194556c52d2f354344f930419eef2dd6267f0 Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Wed, 4 Sep 2013 05:51:59 +0200 Subject: Update to MediaWiki 1.21.2 --- includes/resourceloader/ResourceLoader.php | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) (limited to 'includes/resourceloader') diff --git a/includes/resourceloader/ResourceLoader.php b/includes/resourceloader/ResourceLoader.php index 27f682c2..4e047be4 100644 --- a/includes/resourceloader/ResourceLoader.php +++ b/includes/resourceloader/ResourceLoader.php @@ -175,7 +175,7 @@ class ResourceLoader { $cache->set( $key, $result ); } catch ( Exception $exception ) { // Return exception as a comment - $result = $this->makeComment( $exception->__toString() ); + $result = $this->formatException( $exception ); $this->hasErrors = true; } @@ -461,7 +461,7 @@ class ResourceLoader { $this->preloadModuleInfo( array_keys( $modules ), $context ); } catch( Exception $e ) { // Add exception to the output as a comment - $errors .= $this->makeComment( $e->__toString() ); + $errors .= $this->formatException( $e ); $this->hasErrors = true; } @@ -479,7 +479,7 @@ class ResourceLoader { $mtime = max( $mtime, $module->getModifiedTime( $context ) ); } catch ( Exception $e ) { // Add exception to the output as a comment - $errors .= $this->makeComment( $e->__toString() ); + $errors .= $this->formatException( $e ); $this->hasErrors = true; } } @@ -662,6 +662,22 @@ class ResourceLoader { return "/*\n$encText\n*/\n"; } + /** + * Handle exception display + * + * @param Exception $e to be shown to the user + * @return string sanitized text that can be returned to the user + */ + protected function formatException( $e ) { + global $wgShowExceptionDetails; + + if ( $wgShowExceptionDetails ) { + return $this->makeComment( $e->__toString() ); + } else { + return $this->makeComment( wfMessage( 'internalerror' )->text() ); + } + } + /** * Generates code for a response * @@ -686,7 +702,7 @@ class ResourceLoader { $blobs = MessageBlobStore::get( $this, $modules, $context->getLanguage() ); } catch ( Exception $e ) { // Add exception to the output as a comment - $exceptions .= $this->makeComment( $e->__toString() ); + $exceptions .= $this->formatException( $e ); $this->hasErrors = true; } } else { @@ -792,7 +808,7 @@ class ResourceLoader { } } catch ( Exception $e ) { // Add exception to the output as a comment - $exceptions .= $this->makeComment( $e->__toString() ); + $exceptions .= $this->formatException( $e ); $this->hasErrors = true; // Register module as missing -- cgit v1.2.2