Merge "Add new grammar forms for language names in Russian"
[lhc/web/wiklou.git] / includes / resourceloader / ResourceLoader.php
index 83ee8f9..c20d386 100644 (file)
@@ -208,7 +208,12 @@ class ResourceLoader implements LoggerAwareInterface {
                if ( !$options['cache'] ) {
                        $result = self::applyFilter( $filter, $data, $this->config );
                } else {
-                       $key = wfGlobalCacheKey( 'resourceloader', 'filter', $filter, self::$filterCacheVersion, md5( $data ) );
+                       $key = wfGlobalCacheKey(
+                               'resourceloader',
+                               'filter',
+                               $filter,
+                               self::$filterCacheVersion, md5( $data )
+                       );
                        $cache = wfGetCache( wfIsHHVM() ? CACHE_ACCEL : CACHE_ANYTHING );
                        $cacheEntry = $cache->get( $key );
                        if ( is_string( $cacheEntry ) ) {
@@ -747,18 +752,18 @@ class ResourceLoader implements LoggerAwareInterface {
 
                if ( $context->getImageObj() && $this->errors ) {
                        // We can't show both the error messages and the response when it's an image.
-                       $errorText = '';
-                       foreach ( $this->errors as $error ) {
-                               $errorText .= $error . "\n";
-                       }
-                       $response = $errorText;
+                       $response = implode( "\n\n", $this->errors );
                } elseif ( $this->errors ) {
-                       // Prepend comments indicating errors
-                       $errorText = '';
-                       foreach ( $this->errors as $error ) {
-                               $errorText .= self::makeComment( $error );
+                       $errorText = implode( "\n\n", $this->errors );
+                       $errorResponse = self::makeComment( $errorText );
+                       if ( $context->shouldIncludeScripts() ) {
+                               $errorResponse .= 'if (window.console && console.error) {'
+                                       . Xml::encodeJsCall( 'console.error', array( $errorText ) )
+                                       . "}\n";
                        }
-                       $response = $errorText . $response;
+
+                       // Prepend error info to the response
+                       $response = $errorResponse . $response;
                }
 
                $this->errors = array();
@@ -941,10 +946,10 @@ class ResourceLoader implements LoggerAwareInterface {
                global $wgShowExceptionDetails;
 
                if ( !$wgShowExceptionDetails ) {
-                       return 'Internal error';
+                       return MWExceptionHandler::getPublicLogMessage( $e );
                }
 
-               return $e->__toString();
+               return MWExceptionHandler::getLogMessage( $e );
        }
 
        /**
@@ -1380,7 +1385,8 @@ MESSAGE;
         * @return string
         */
        public static function makeLoaderConditionalScript( $script ) {
-               return "window.RLQ = window.RLQ || []; window.RLQ.push( function () {\n" . trim( $script ) . "\n} );";
+               return "window.RLQ = window.RLQ || []; window.RLQ.push( function () {\n" .
+                       trim( $script ) . "\n} );";
        }
 
        /**