Document return string as JavaScript code
[lhc/web/wiklou.git] / includes / resourceloader / ResourceLoader.php
index e72eaf2..c2faf48 100644 (file)
@@ -27,6 +27,7 @@ use Psr\Log\LoggerAwareInterface;
 use Psr\Log\LoggerInterface;
 use Psr\Log\NullLogger;
 use WrappedString\WrappedString;
+use Wikimedia\Rdbms\DBConnectionError;
 
 /**
  * Dynamic JavaScript and CSS resource loading system.
@@ -252,7 +253,6 @@ class ResourceLoader implements LoggerAwareInterface {
 
                // Register core modules
                $this->register( include "$IP/resources/Resources.php" );
-               $this->register( include "$IP/resources/ResourcesOOUI.php" );
                // Register extension modules
                $this->register( $config->get( 'ResourceModules' ) );
 
@@ -540,6 +540,10 @@ class ResourceLoader implements LoggerAwareInterface {
                        if ( isset( $info['object'] ) ) {
                                // Object given in info array
                                $object = $info['object'];
+                       } elseif ( isset( $info['factory'] ) ) {
+                               $object = call_user_func( $info['factory'], $info );
+                               $object->setConfig( $this->getConfig() );
+                               $object->setLogger( $this->logger );
                        } else {
                                if ( !isset( $info['class'] ) ) {
                                        $class = 'ResourceLoaderFileModule';
@@ -569,7 +573,12 @@ class ResourceLoader implements LoggerAwareInterface {
                        return false;
                }
                $info = $this->moduleInfos[$name];
-               if ( isset( $info['object'] ) || isset( $info['class'] ) ) {
+               if (
+                       isset( $info['object'] ) ||
+                       // This special case is dumb, but we need $wgResourceModuleSkinStyles
+                       // to work for 'oojs-ui-core.styles'. See T167042.
+                       ( isset( $info['class'] ) && $info['class'] !== 'ResourceLoaderOOUIFileModule' )
+               ) {
                        return false;
                }
                return true;
@@ -1161,7 +1170,7 @@ MESSAGE;
         * @param array $templates Keys are name of templates and values are the source of
         *   the template.
         * @throws MWException
-        * @return string
+        * @return string JavaScript code
         */
        protected static function makeLoaderImplementScript(
                $name, $scripts, $styles, $messages, $templates
@@ -1191,7 +1200,7 @@ MESSAGE;
         *
         * @param mixed $messages Either an associative array mapping message key to value, or a
         *   JSON-encoded message blob containing the same data, wrapped in an XmlJsCode object.
-        * @return string
+        * @return string JavaScript code
         */
        public static function makeMessageSetScript( $messages ) {
                return Xml::encodeJsCall(
@@ -1247,7 +1256,7 @@ MESSAGE;
         *
         * @param string $name
         * @param string $state
-        * @return string
+        * @return string JavaScript code
         */
        public static function makeLoaderStateScript( $name, $state = null ) {
                if ( is_array( $name ) ) {
@@ -1277,7 +1286,7 @@ MESSAGE;
         * @param string $group Group which the module is in.
         * @param string $source Source of the module, or 'local' if not foreign.
         * @param string $script JavaScript code
-        * @return string
+        * @return string JavaScript code
         */
        public static function makeCustomLoaderScript( $name, $version, $dependencies,
                $group, $source, $script
@@ -1349,7 +1358,7 @@ MESSAGE;
         * @param string $group Group which the module is in
         * @param string $source Source of the module, or 'local' if not foreign
         * @param string $skip Script body of the skip function
-        * @return string
+        * @return string JavaScript code
         */
        public static function makeLoaderRegisterScript( $name, $version = null,
                $dependencies = null, $group = null, $source = null, $skip = null
@@ -1403,7 +1412,7 @@ MESSAGE;
         *
         * @param string $id Source ID
         * @param string $loadUrl load.php url
-        * @return string
+        * @return string JavaScript code
         */
        public static function makeLoaderSourcesScript( $id, $loadUrl = null ) {
                if ( is_array( $id ) ) {
@@ -1427,7 +1436,7 @@ MESSAGE;
         *
         * @deprecated since 1.25; use makeInlineScript instead
         * @param string $script JavaScript code
-        * @return string
+        * @return string JavaScript code
         */
        public static function makeLoaderConditionalScript( $script ) {
                return '(window.RLQ=window.RLQ||[]).push(function(){' .
@@ -1457,7 +1466,7 @@ MESSAGE;
         * the given value.
         *
         * @param array $configuration List of configuration values keyed by variable name
-        * @return string
+        * @return string JavaScript code
         */
        public static function makeConfigSetScript( array $configuration ) {
                return Xml::encodeJsCall(