diff options
author | daniel <daniel.kinzler@wikimedia.de> | 2016-05-13 21:27:06 +0200 |
---|---|---|
committer | BryanDavis <bdavis@wikimedia.org> | 2016-05-17 15:24:31 +0000 |
commit | fc1d4d79602415d1362de9286b0729bd86d03fc1 (patch) | |
tree | 8af4aab8777d23da8a019d92b1e51ba8bc28c12b /includes/cache | |
parent | 045ca4ca47eb3b9120599d6964b33c15bd96b6e7 (diff) | |
download | mediawikicore-fc1d4d79602415d1362de9286b0729bd86d03fc1.tar.gz mediawikicore-fc1d4d79602415d1362de9286b0729bd86d03fc1.zip |
Fix installer issues introduces by MediaWikiServices
This fixes three issues with the installer:
1) Make sure LocalizationCache can find the installer's i18n files.
2) Make sure we don't try to use an SqlBagOStuff for caching before we have
a functioning database.
3) Don't try to output HTML when redirecting (this is unrelated to
MediaWikiServices, but came up during testing)
Bug: T135169
Change-Id: I7caa932024cd771d6fa226a3ac6001c3148ecc9c
Diffstat (limited to 'includes/cache')
-rw-r--r-- | includes/cache/CacheDependency.php | 29 | ||||
-rw-r--r-- | includes/cache/localisation/LocalisationCache.php | 13 |
2 files changed, 38 insertions, 4 deletions
diff --git a/includes/cache/CacheDependency.php b/includes/cache/CacheDependency.php index 2d29d8651306..a59ba97d0a00 100644 --- a/includes/cache/CacheDependency.php +++ b/includes/cache/CacheDependency.php @@ -20,6 +20,7 @@ * @file * @ingroup Cache */ +use MediaWiki\MediaWikiServices; /** * This class stores an arbitrary value along with its dependencies. @@ -247,6 +248,34 @@ class GlobalDependency extends CacheDependency { /** * @ingroup Cache */ +class MainConfigDependency extends CacheDependency { + private $name; + private $value; + + function __construct( $name ) { + $this->name = $name; + $this->value = $this->getConfig()->get( $this->name ); + } + + private function getConfig() { + return MediaWikiServices::getInstance()->getMainConfig(); + } + + /** + * @return bool + */ + function isExpired() { + if ( !$this->getConfig()->has( $this->name ) ) { + return true; + } + + return $this->getConfig()->get( $this->name ) != $this->value; + } +} + +/** + * @ingroup Cache + */ class ConstantDependency extends CacheDependency { private $name; private $value; diff --git a/includes/cache/localisation/LocalisationCache.php b/includes/cache/localisation/LocalisationCache.php index dd7d81a33c04..0fb9ed856100 100644 --- a/includes/cache/localisation/LocalisationCache.php +++ b/includes/cache/localisation/LocalisationCache.php @@ -23,6 +23,7 @@ use Cdb\Reader as CdbReader; use Cdb\Writer as CdbWriter; use CLDRPluralRuleParser\Evaluator; +use MediaWiki\MediaWikiServices; /** * Class for caching the contents of localisation files, Messages*.php @@ -802,12 +803,15 @@ class LocalisationCache { * @return array */ public function getMessagesDirs() { - global $wgMessagesDirs, $IP; + global $IP; + + $config = MediaWikiServices::getInstance()->getMainConfig(); + $messagesDirs = $config->get( 'MessagesDirs' ); return [ 'core' => "$IP/languages/i18n", 'api' => "$IP/includes/api/i18n", 'oojs-ui' => "$IP/resources/lib/oojs-ui/i18n", - ] + $wgMessagesDirs; + ] + $messagesDirs; } /** @@ -958,8 +962,9 @@ class LocalisationCache { # Add cache dependencies for any referenced globals $deps['wgExtensionMessagesFiles'] = new GlobalDependency( 'wgExtensionMessagesFiles' ); - // $wgMessagesDirs is used in LocalisationCache::getMessagesDirs() - $deps['wgMessagesDirs'] = new GlobalDependency( 'wgMessagesDirs' ); + // The 'MessagesDirs' config setting is used in LocalisationCache::getMessagesDirs(). + // We use the key 'wgMessagesDirs' for historical reasons. + $deps['wgMessagesDirs'] = new MainConfigDependency( 'MessagesDirs' ); $deps['version'] = new ConstantDependency( 'LocalisationCache::VERSION' ); # Add dependencies to the cache entry |