Merge "Use WIS:addWatchBatchForUser in SpecialEditWatchlist"
[lhc/web/wiklou.git] / includes / installer / WebInstallerOutput.php
index 44ca7d3..b4c8aa8 100644 (file)
@@ -126,49 +126,52 @@ class WebInstallerOutput {
        public function getCSS() {
                global $wgStyleDirectory;
 
-               $moduleNames = array(
+               $moduleNames = [
                        // See SkinTemplate::setupSkinUserCss
                        'mediawiki.legacy.shared',
                        // See Vector::setupSkinUserCss
                        'mediawiki.skinning.interface',
-               );
+               ];
 
-               if ( file_exists( "$wgStyleDirectory/Vector/Vector.php" ) ) {
+               $resourceLoader = new ResourceLoader();
+
+               if ( file_exists( "$wgStyleDirectory/Vector/skin.json" ) ) {
                        // Force loading Vector skin if available as a fallback skin
                        // for whatever ResourceLoader wants to have as the default.
-
-                       // Include instead of require, as this will work without it, it will just look bad.
-                       // We need the 'global' statement for $wgResourceModules because the Vector skin adds the
-                       // definitions for its RL modules there that we use implicitly below.
-
-                       // @codingStandardsIgnoreStart
-                       global $wgResourceModules; // This is NOT UNUSED!
-                       // @codingStandardsIgnoreEnd
-
-                       include_once "$wgStyleDirectory/Vector/Vector.php";
+                       $registry = new ExtensionRegistry();
+                       $data = $registry->readFromQueue( [
+                               "$wgStyleDirectory/Vector/skin.json" => 1,
+                       ] );
+                       if ( isset( $data['globals']['wgResourceModules'] ) ) {
+                               $resourceLoader->register( $data['globals']['wgResourceModules'] );
+                       }
 
                        $moduleNames[] = 'skins.vector.styles';
                }
 
                $moduleNames[] = 'mediawiki.legacy.config';
 
-               $resourceLoader = new ResourceLoader();
-               $rlContext = new ResourceLoaderContext( $resourceLoader, new FauxRequest( array(
+               $rlContext = new ResourceLoaderContext( $resourceLoader, new FauxRequest( [
                                'debug' => 'true',
                                'lang' => $this->getLanguageCode(),
                                'only' => 'styles',
-               ) ) );
+               ] ) );
 
-               $styles = array();
+               $styles = [];
                foreach ( $moduleNames as $moduleName ) {
                        /** @var ResourceLoaderFileModule $module */
                        $module = $resourceLoader->getModule( $moduleName );
+                       if ( !$module ) {
+                               // T98043: Don't fatal, but it won't look as pretty.
+                               continue;
+                       }
 
                        // Based on: ResourceLoaderFileModule::getStyles (without the DB query)
                        $styles = array_merge( $styles, ResourceLoader::makeCombinedStyles(
                                $module->readStyleFiles(
                                        $module->getStyleFiles( $rlContext ),
-                                       $module->getFlip( $rlContext )
+                                       $module->getFlip( $rlContext ),
+                                       $rlContext
                        ) ) );
                }
 
@@ -225,10 +228,10 @@ class WebInstallerOutput {
         * @return string[]
         */
        public function getHeadAttribs() {
-               return array(
+               return [
                        'dir' => $this->getDir(),
                        'lang' => wfBCP47( $this->getLanguageCode() ),
-               );
+               ];
        }
 
        /**
@@ -270,7 +273,7 @@ class WebInstallerOutput {
        <?php echo Html::linkedScript( 'config.js' ) . "\n"; ?>
 </head>
 
-<?php echo Html::openElement( 'body', array( 'class' => $this->getDir() ) ) . "\n"; ?>
+<?php echo Html::openElement( 'body', [ 'class' => $this->getDir() ] ) . "\n"; ?>
 <div id="mw-page-base"></div>
 <div id="mw-head-base"></div>
 <div id="content" class="mw-body">