本文整理汇总了PHP中MediaWiki\MediaWikiServices::disableStorageBackend方法的典型用法代码示例。如果您正苦于以下问题:PHP MediaWikiServices::disableStorageBackend方法的具体用法?PHP MediaWikiServices::disableStorageBackend怎么用?PHP MediaWikiServices::disableStorageBackend使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MediaWiki\MediaWikiServices
的用法示例。
在下文中一共展示了MediaWikiServices::disableStorageBackend方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* Constructor, always call this from child classes.
*/
public function __construct()
{
global $wgMemc, $wgUser, $wgObjectCaches;
$defaultConfig = new GlobalVarConfig();
// all the stuff from DefaultSettings.php
$installerConfig = self::getInstallerConfig($defaultConfig);
// Reset all services and inject config overrides
MediaWiki\MediaWikiServices::resetGlobalInstance($installerConfig);
// Don't attempt to load user language options (T126177)
// This will be overridden in the web installer with the user-specified language
RequestContext::getMain()->setLanguage('en');
// Disable the i18n cache
// TODO: manage LocalisationCache singleton in MediaWikiServices
Language::getLocalisationCache()->disableBackend();
// Disable all global services, since we don't have any configuration yet!
MediaWiki\MediaWikiServices::disableStorageBackend();
// 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().
$wgUser = User::newFromId(0);
RequestContext::getMain()->setUser($wgUser);
$this->settings = $this->internalDefaults;
foreach ($this->defaultVarNames as $var) {
$this->settings[$var] = $GLOBALS[$var];
}
$this->doEnvironmentPreps();
$this->compiledDBs = [];
foreach (self::getDBTypes() as $type) {
$installer = $this->getDBInstaller($type);
if (!$installer->isCompiled()) {
continue;
}
$this->compiledDBs[] = $type;
}
$this->parserTitle = Title::newFromText('Installer');
$this->parserOptions = new ParserOptions($wgUser);
// language will be wrong :(
$this->parserOptions->setEditSection(false);
}
示例2: disableBackend
/**
* Disables all access to the load balancer, will cause all database access
* to throw a DBAccessError
*/
public static function disableBackend()
{
MediaWikiServices::disableStorageBackend();
}
示例3: testDisableStorageBackend
public function testDisableStorageBackend()
{
$newServices = $this->newMediaWikiServices();
$oldServices = MediaWikiServices::forceGlobalInstance($newServices);
$lbFactory = $this->getMockBuilder('LBFactorySimple')->disableOriginalConstructor()->getMock();
$lbFactory->expects($this->once())->method('destroy');
$newServices->redefineService('DBLoadBalancerFactory', function () use($lbFactory) {
return $lbFactory;
});
// force the service to become active, so we can check that it does get destroyed
$newServices->getService('DBLoadBalancerFactory');
MediaWikiServices::disableStorageBackend();
// should destroy DBLoadBalancerFactory
try {
MediaWikiServices::getInstance()->getService('DBLoadBalancerFactory');
$this->fail('DBLoadBalancerFactory shoudl have been disabled');
} catch (ServiceDisabledException $ex) {
// ok, as expected
} catch (Throwable $ex) {
$this->fail('ServiceDisabledException expected, caught ' . get_class($ex));
}
MediaWikiServices::forceGlobalInstance($oldServices);
$newServices->destroy();
}