From: saper Date: Tue, 26 Aug 2014 19:38:41 +0000 (+0200) Subject: Installer: Do not use Vector skin if not installed X-Git-Tag: 1.31.0-rc.0~14213^2 X-Git-Url: https://git.cyclocoop.org/%7B%24www_url%7Dadmin/compta/comptes/ajouter.php?a=commitdiff_plain;h=8ac77bfbd3b5014b7665340f35de667e38072b73;p=lhc%2Fweb%2Fwiklou.git Installer: Do not use Vector skin if not installed MediaWiki installer works fine in a bareskin mode without Vector features, so do not throw errors in the PHP error log just because we don't have "skins" project extracted. The message in the PHP error log: Warning: include_once(w/skins/Vector/Vector.php): failed to open stream: No such file or directory in w/includes/installer/WebInstallerOutput.php on line 135 Stack trace: 1. {main}() w/mw-config/index.php:0 2. wfInstallerMain() w/mw-config/index.php:38 3. WebInstaller->execute() w/mw-config/index.php:79 4. WebInstaller->outputCss() w/includes/installer/WebInstaller.php:185 5. WebInstallerOutput->getCSS() w/includes/installer/WebInstaller.php:1200 Change-Id: I7b8bd77f5868af2ccf464e48db771f2e8e0472ff --- diff --git a/includes/installer/WebInstallerOutput.php b/includes/installer/WebInstallerOutput.php index ccaf52385d..3094d5571b 100644 --- a/includes/installer/WebInstallerOutput.php +++ b/includes/installer/WebInstallerOutput.php @@ -124,53 +124,55 @@ class WebInstallerOutput { * @return string */ public function getCSS() { - // Horrible, horrible hack: the installer is currently hardcoded to use the Vector skin, so load - // it here. 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 global $wgStyleDirectory; - include_once "$wgStyleDirectory/Vector/Vector.php"; $moduleNames = array( // See SkinTemplate::setupSkinUserCss 'mediawiki.legacy.shared', // See Vector::setupSkinUserCss 'mediawiki.skinning.interface', - 'skins.vector.styles', - - 'mediawiki.legacy.config', ); - $css = ''; + if ( file_exists( "$wgStyleDirectory/Vector/Vector.php" ) ) { + // 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"; + + $moduleNames[] = 'skins.vector.styles'; + } + + $moduleNames[] = 'mediawiki.legacy.config'; $resourceLoader = new ResourceLoader(); $rlContext = new ResourceLoaderContext( $resourceLoader, new FauxRequest( array( 'debug' => 'true', 'lang' => $this->getLanguageCode(), 'only' => 'styles', - 'skin' => 'vector', ) ) ); + + $styles = array(); foreach ( $moduleNames as $moduleName ) { /** @var ResourceLoaderFileModule $module */ $module = $resourceLoader->getModule( $moduleName ); - // One of the modules will be missing if Vector is unavailable - if ( !$module ) { - continue; - } // Based on: ResourceLoaderFileModule::getStyles (without the DB query) - $styles = ResourceLoader::makeCombinedStyles( $module->readStyleFiles( - $module->getStyleFiles( $rlContext ), - $module->getFlip( $rlContext ) - ) ); - - $css .= implode( "\n", $styles ); + $styles = array_merge( $styles, ResourceLoader::makeCombinedStyles( + $module->readStyleFiles( + $module->getStyleFiles( $rlContext ), + $module->getFlip( $rlContext ) + ) ) ); } - return $css; + return implode( "\n", $styles ); } /**