/** * Get the stylesheet of the MediaWiki skin. * * @return string */ public function getCSS() { global $wgStyleDirectory; $moduleNames = array('mediawiki.legacy.shared', 'mediawiki.skinning.interface'); $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. $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'; $rlContext = new ResourceLoaderContext($resourceLoader, new FauxRequest(array('debug' => 'true', 'lang' => $this->getLanguageCode(), 'only' => 'styles'))); $styles = array(); 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)))); } return implode("\n", $styles); }
if (strval($fileName) === '') { continue; } if (empty($mmfl['quiet'])) { fwrite(STDERR, "Loading data from {$fileName}\n"); } // Using extension.json or skin.json if (substr($fileName, -strlen('.json')) === '.json') { $queue[$fileName] = 1; } else { require_once $fileName; } } if ($queue) { $registry = new ExtensionRegistry(); $data = $registry->readFromQueue($queue); foreach (array('wgExtensionMessagesFiles', 'wgMessagesDirs') as $var) { if (isset($data['globals'][$var])) { $GLOBALS[$var] = array_merge($data['globals'][$var], $GLOBALS[$var]); } } } fwrite(STDERR, "\n"); $s = "<" . "?php\n" . "## This file is generated by mergeMessageFileList.php. Do not edit it directly.\n\n" . "if ( defined( 'MW_NO_EXTENSION_MESSAGES' ) ) return;\n\n" . '$wgExtensionMessagesFiles = ' . var_export($wgExtensionMessagesFiles, true) . ";\n\n" . '$wgMessagesDirs = ' . var_export($wgMessagesDirs, true) . ";\n\n"; $dirs = array($IP, dirname(__DIR__), realpath($IP)); foreach ($dirs as $dir) { $s = preg_replace("/'" . preg_quote($dir, '/') . "([^']*)'/", '"$IP\\1"', $s); } if (isset($mmfl['output'])) { file_put_contents($mmfl['output'], $s); } else {
/** * Installs the auto-detected extensions. * * @return Status */ protected function includeExtensions() { global $IP; $exts = $this->getVar('_Extensions'); $IP = $this->getVar('IP'); /** * We need to include DefaultSettings before including extensions to avoid * warnings about unset variables. However, the only thing we really * want here is $wgHooks['LoadExtensionSchemaUpdates']. This won't work * if the extension has hidden hook registration in $wgExtensionFunctions, * but we're not opening that can of worms * @see https://phabricator.wikimedia.org/T28857 */ global $wgAutoloadClasses; $wgAutoloadClasses = []; $queue = []; require "{$IP}/includes/DefaultSettings.php"; foreach ($exts as $e) { if (file_exists("{$IP}/extensions/{$e}/extension.json")) { $queue["{$IP}/extensions/{$e}/extension.json"] = 1; } else { require_once "{$IP}/extensions/{$e}/{$e}.php"; } } $registry = new ExtensionRegistry(); $data = $registry->readFromQueue($queue); $wgAutoloadClasses += $data['autoload']; $hooksWeWant = isset($wgHooks['LoadExtensionSchemaUpdates']) ? $wgHooks['LoadExtensionSchemaUpdates'] : []; if (isset($data['globals']['wgHooks']['LoadExtensionSchemaUpdates'])) { $hooksWeWant = array_merge_recursive($hooksWeWant, $data['globals']['wgHooks']['LoadExtensionSchemaUpdates']); } // Unset everyone else's hooks. Lord knows what someone might be doing // in ParserFirstCallInit (see bug 27171) $GLOBALS['wgHooks'] = ['LoadExtensionSchemaUpdates' => $hooksWeWant]; return Status::newGood(); }