From 3c1d3e2bc6dc152e6846cb8fed13c60bc0948dec Mon Sep 17 00:00:00 2001 From: Kunal Mehta Date: Mon, 4 May 2015 11:41:13 -0700 Subject: [PATCH] installer: Read styles from Vector's skin.json Vector now has a skin.json and the PHP entry point is just a stub, so including it doesn't do anything. We can read from the skin.json file and register the module properly instead of depending upon implicit globals. Also make ExtensionRegistry::__construct() not fail if $wgObjectCaches is not set up properly, which is the case sometimes in the installer. Bug: T98043 Change-Id: I5a653b095665092f8a27416b8a7f28ebf7d4d8c1 --- includes/installer/WebInstallerOutput.php | 26 +++++++++++---------- includes/registration/ExtensionRegistry.php | 9 ++++++- 2 files changed, 22 insertions(+), 13 deletions(-) diff --git a/includes/installer/WebInstallerOutput.php b/includes/installer/WebInstallerOutput.php index 44ca7d3001..0ccdb11af9 100644 --- a/includes/installer/WebInstallerOutput.php +++ b/includes/installer/WebInstallerOutput.php @@ -133,26 +133,24 @@ class WebInstallerOutput { '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( array( + "$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( 'debug' => 'true', 'lang' => $this->getLanguageCode(), @@ -163,6 +161,10 @@ class WebInstallerOutput { 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( diff --git a/includes/registration/ExtensionRegistry.php b/includes/registration/ExtensionRegistry.php index 74d49bc108..d938f07272 100644 --- a/includes/registration/ExtensionRegistry.php +++ b/includes/registration/ExtensionRegistry.php @@ -62,7 +62,14 @@ class ExtensionRegistry { } public function __construct() { - $this->cache = ObjectCache::newAccelerator( array(), CACHE_NONE ); + // We use a try/catch instead of the $fallback parameter because + // we don't want to fail here if $wgObjectCaches is not configured + // properly for APC setup + try { + $this->cache = ObjectCache::newAccelerator( array() ); + } catch ( MWException $e ) { + $this->cache = new EmptyBagOStuff(); + } } /** -- 2.20.1