Use DB domain in JobQueueGroup and make WikiMap domain ID methods stricter
[lhc/web/wiklou.git] / includes / resourceloader / ResourceLoader.php
index 5621dcd..2fc81e3 100644 (file)
@@ -550,11 +550,7 @@ class ResourceLoader implements LoggerAwareInterface {
                                $object->setConfig( $this->getConfig() );
                                $object->setLogger( $this->logger );
                        } else {
-                               if ( !isset( $info['class'] ) ) {
-                                       $class = ResourceLoaderFileModule::class;
-                               } else {
-                                       $class = $info['class'];
-                               }
+                               $class = $info['class'] ?? ResourceLoaderFileModule::class;
                                /** @var ResourceLoaderModule $object */
                                $object = new $class( $info );
                                $object->setConfig( $this->getConfig() );
@@ -1364,7 +1360,7 @@ MESSAGE;
         * - new XmlJsCode( '{}' )
         * - new stdClass() // (object) []
         *
-        * @param Array $array
+        * @param array $array
         */
        private static function trimArray( array &$array ) {
                $i = count( $array );
@@ -1524,13 +1520,21 @@ MESSAGE;
         *
         * @param array $configuration List of configuration values keyed by variable name
         * @return string JavaScript code
+        * @throws Exception
         */
        public static function makeConfigSetScript( array $configuration ) {
-               return Xml::encodeJsCall(
+               $js = Xml::encodeJsCall(
                        'mw.config.set',
                        [ $configuration ],
                        self::inDebugMode()
                );
+               if ( $js === false ) {
+                       throw new Exception(
+                               'JSON serialization of config data failed. ' .
+                               'This usually means the config data is not valid UTF-8.'
+                       );
+               }
+               return $js;
        }
 
        /**
@@ -1584,6 +1588,9 @@ MESSAGE;
         * Global state and $wgRequest are evil, but we're using it right
         * now and sometimes we need to be able to force ResourceLoader to
         * re-evaluate the context because it has changed (e.g. in the test suite).
+        *
+        * @internal For use by unit tests
+        * @codeCoverageIgnore
         */
        public static function clearCache() {
                self::$debugMode = null;