Merge "Introduce RevisionRecord::isReadForInsertion"
[lhc/web/wiklou.git] / includes / resourceloader / ResourceLoader.php
index fc0ca1d..9764549 100644 (file)
@@ -627,14 +627,13 @@ class ResourceLoader implements LoggerAwareInterface {
        /**
         * Add an error to the 'errors' array and log it.
         *
-        * Should only be called from within respond().
-        *
+        * @private For internal use by ResourceLoader and ResourceLoaderStartUpModule.
         * @since 1.29
         * @param Exception $e
         * @param string $msg
         * @param array $context
         */
-       protected function outputErrorAndLog( Exception $e, $msg, array $context = [] ) {
+       public function outputErrorAndLog( Exception $e, $msg, array $context = [] ) {
                MWExceptionHandler::logException( $e );
                $this->logger->warning(
                        $msg,
@@ -659,9 +658,8 @@ class ResourceLoader implements LoggerAwareInterface {
                        try {
                                return $this->getModule( $module )->getVersionHash( $context );
                        } catch ( Exception $e ) {
-                               // If modules fail to compute a version, do still consider the versions
-                               // of other modules - don't set an empty string E-Tag for the whole request.
-                               // See also T152266 and StartupModule::getModuleRegistrations().
+                               // If modules fail to compute a version, don't fail the request (T152266)
+                               // and still compute versions of other modules.
                                $this->outputErrorAndLog( $e,
                                        'Calculating version for "{module}" failed: {exception}',
                                        [
@@ -1455,24 +1453,19 @@ MESSAGE;
         *   - ResourceLoader::makeLoaderSourcesScript( [ $id1 => $loadUrl, $id2 => $loadUrl, ... ] );
         *       Register sources with the given IDs and properties.
         *
-        * @param string $id Source ID
+        * @param string|array $sources Source ID
         * @param string|null $loadUrl load.php url
         * @return string JavaScript code
         */
-       public static function makeLoaderSourcesScript( $id, $loadUrl = null ) {
-               if ( is_array( $id ) ) {
-                       return Xml::encodeJsCall(
-                               'mw.loader.addSource',
-                               [ $id ],
-                               self::inDebugMode()
-                       );
-               } else {
-                       return Xml::encodeJsCall(
-                               'mw.loader.addSource',
-                               [ $id, $loadUrl ],
-                               self::inDebugMode()
-                       );
+       public static function makeLoaderSourcesScript( $sources, $loadUrl = null ) {
+               if ( !is_array( $sources ) ) {
+                       $sources = [ $sources => $loadUrl ];
                }
+               return Xml::encodeJsCall(
+                       'mw.loader.addSource',
+                       [ $sources ],
+                       self::inDebugMode()
+               );
        }
 
        /**