'MagicWord' => __DIR__ . '/includes/MagicWord.php',
'MagicWordArray' => __DIR__ . '/includes/MagicWordArray.php',
'MailAddress' => __DIR__ . '/includes/mail/MailAddress.php',
+ 'MainConfigDependency' => __DIR__ . '/includes/cache/CacheDependency.php',
'Maintenance' => __DIR__ . '/maintenance/Maintenance.php',
'MaintenanceFormatInstallDoc' => __DIR__ . '/maintenance/formatInstallDoc.php',
'MakeTestEdits' => __DIR__ . '/maintenance/makeTestEdits.php',
use LoadBalancer;
use MediaWiki\Services\ServiceContainer;
use MWException;
+use ObjectCache;
use ResourceLoader;
use SearchEngine;
use SearchEngineConfig;
foreach ( $destroy as $name ) {
$services->disableService( $name );
}
+
+ ObjectCache::clear();
}
/**
* @file
* @ingroup Cache
*/
+use MediaWiki\MediaWikiServices;
/**
* This class stores an arbitrary value along with its dependencies.
}
}
+/**
+ * @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
*/
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
* @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;
}
/**
# 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
* @file
* @ingroup Deployment
*/
+use MediaWiki\MediaWikiServices;
/**
* This documentation group collects source code files with deployment functionality.
$configOverrides->set( 'MessagesDirs', $messageDirs );
- return new MultiConfig( [ $configOverrides, $baseConfig ] );
+ $installerConfig = new MultiConfig( [ $configOverrides, $baseConfig ] );
+
+ // make sure we use the installer config as the main config
+ $configRegistry = $baseConfig->get( 'ConfigRegistry' );
+ $configRegistry['main'] = function() use ( $installerConfig ) {
+ return $installerConfig;
+ };
+
+ $configOverrides->set( 'ConfigRegistry', $configRegistry );
+
+ return $installerConfig;
}
/**
* Constructor, always call this from child classes.
*/
public function __construct() {
- global $wgMemc, $wgUser;
+ global $wgMemc, $wgUser, $wgObjectCaches;
$defaultConfig = new GlobalVarConfig(); // all the stuff from DefaultSettings.php
$installerConfig = self::getInstallerConfig( $defaultConfig );
// Disable object cache (otherwise CACHE_ANYTHING will try CACHE_DB and
// SqlBagOStuff will then throw since we just disabled wfGetDB)
+ $wgObjectCaches = MediaWikiServices::getInstance()->getMainConfig()->get( 'ObjectCaches' );
$wgMemc = ObjectCache::getInstance( CACHE_NONE );
// Having a user with id = 0 safeguards us from DB access via User::loadOptions().
public function output() {
$this->flush();
- $this->outputFooter();
+
+ if ( !$this->redirectTarget ) {
+ $this->outputFooter();
+ }
}
/**
use MediaWiki\Logger\LoggerFactory;
use MediaWiki\MediaWikiServices;
+use MediaWiki\Services\ServiceDisabledException;
/**
* Functions to get cache objects
return self::getInstance( $candidate );
}
}
- return self::getInstance( CACHE_DB );
+
+ try {
+ // Make sure we actually have a DB backend before falling back to CACHE_DB
+ MediaWikiServices::getInstance()->getDBLoadBalancer();
+ $candidate = CACHE_DB;
+ } catch ( ServiceDisabledException $e ) {
+ // The LoadBalancer is disabled, probably because
+ // MediaWikiServices::disableStorageBackend was called.
+ $candidate = CACHE_NONE;
+ }
+
+ return self::getInstance( $candidate );
}
/**