当前位置: 首页>>代码示例>>PHP>>正文


PHP MediaWikiServices::resetGlobalInstance方法代码示例

本文整理汇总了PHP中MediaWiki\MediaWikiServices::resetGlobalInstance方法的典型用法代码示例。如果您正苦于以下问题:PHP MediaWikiServices::resetGlobalInstance方法的具体用法?PHP MediaWikiServices::resetGlobalInstance怎么用?PHP MediaWikiServices::resetGlobalInstance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在MediaWiki\MediaWikiServices的用法示例。


在下文中一共展示了MediaWikiServices::resetGlobalInstance方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: GlobalVarConfig

    // specifically set it to the (undocumented) 'warn'.
    $wgPHPSessionHandling = MW_NO_SESSION === 'warn' ? 'warn' : 'disable';
}
Profiler::instance()->scopedProfileOut($ps_default);
// Disable MWDebug for command line mode, this prevents MWDebug from eating up
// all the memory from logging SQL queries on maintenance scripts
global $wgCommandLineMode;
if ($wgDebugToolbar && !$wgCommandLineMode) {
    MWDebug::init();
}
if (!class_exists('AutoLoader')) {
    require_once "{$IP}/includes/AutoLoader.php";
}
// Reset the global service locator, so any services that have already been created will be
// re-created while taking into account any custom settings and extensions.
MediaWikiServices::resetGlobalInstance(new GlobalVarConfig(), 'quick');
if ($wgSharedDB && $wgSharedTables) {
    // Apply $wgSharedDB table aliases for the local LB (all non-foreign DB connections)
    MediaWikiServices::getInstance()->getDBLoadBalancer()->setTableAliases(array_fill_keys($wgSharedTables, ['dbname' => $wgSharedDB, 'schema' => $wgSharedSchema, 'prefix' => $wgSharedPrefix]));
}
// Define a constant that indicates that the bootstrapping of the service locator
// is complete.
define('MW_SERVICE_BOOTSTRAP_COMPLETE', 1);
// Install a header callback to prevent caching of responses with cookies (T127993)
if (!$wgCommandLineMode) {
    header_register_callback(function () {
        $headers = [];
        foreach (headers_list() as $header) {
            list($name, $value) = explode(':', $header, 2);
            $headers[strtolower(trim($name))][] = trim($value);
        }
开发者ID:paladox,项目名称:mediawiki,代码行数:31,代码来源:Setup.php

示例2: __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);
 }
开发者ID:paladox,项目名称:mediawiki,代码行数:44,代码来源:Installer.php

示例3: enableLB

 /**
  * Set up LBFactory so that wfGetDB() etc. works.
  * We set up a special LBFactory instance which returns the current
  * installer connection.
  */
 public function enableLB()
 {
     $status = $this->getConnection();
     if (!$status->isOK()) {
         throw new MWException(__METHOD__ . ': unexpected DB connection error');
     }
     \MediaWiki\MediaWikiServices::resetGlobalInstance();
     $services = \MediaWiki\MediaWikiServices::getInstance();
     $connection = $status->value;
     $services->redefineService('DBLoadBalancerFactory', function () use($connection) {
         return new LBFactorySingle(['connection' => $connection]);
     });
 }
开发者ID:claudinec,项目名称:galan-wiki,代码行数:18,代码来源:DatabaseInstaller.php

示例4: testResetGlobalInstance_quick

 public function testResetGlobalInstance_quick()
 {
     $newServices = $this->newMediaWikiServices();
     $oldServices = MediaWikiServices::forceGlobalInstance($newServices);
     $service1 = $this->getMock(SalvageableService::class);
     $service1->expects($this->never())->method('salvage');
     $service2 = $this->getMock(SalvageableService::class);
     $service2->expects($this->once())->method('salvage')->with($service1);
     // sequence of values the instantiator will return
     $instantiatorReturnValues = [$service1, $service2];
     $newServices->defineService('Test', function () use(&$instantiatorReturnValues) {
         return array_shift($instantiatorReturnValues);
     });
     // force instantiation
     $newServices->getService('Test');
     MediaWikiServices::resetGlobalInstance($this->newTestConfig(), 'quick');
     $theServices = MediaWikiServices::getInstance();
     $this->assertSame($service2, $theServices->getService('Test'));
     $this->assertNotSame($theServices, $newServices);
     $this->assertNotSame($theServices, $oldServices);
     MediaWikiServices::forceGlobalInstance($oldServices);
 }
开发者ID:claudinec,项目名称:galan-wiki,代码行数:22,代码来源:MediaWikiServicesTest.php

示例5: resetGlobalServices

 /**
  * Reset global services, and install testing environment.
  * This is the testing equivalent of MediaWikiServices::resetGlobalInstance().
  * This should only be used to set up the testing environment, not when
  * running unit tests. Use MediaWikiTestCase::overrideMwServices() for that.
  *
  * @see MediaWikiServices::resetGlobalInstance()
  * @see prepareServices()
  * @see MediaWikiTestCase::overrideMwServices()
  *
  * @param Config|null $bootstrapConfig The bootstrap config to use with the new
  *        MediaWikiServices.
  */
 protected static function resetGlobalServices(Config $bootstrapConfig = null)
 {
     $oldServices = MediaWikiServices::getInstance();
     $oldConfigFactory = $oldServices->getConfigFactory();
     $testConfig = self::makeTestConfig($bootstrapConfig);
     MediaWikiServices::resetGlobalInstance($testConfig);
     $serviceLocator = MediaWikiServices::getInstance();
     self::installTestServices($oldConfigFactory, $serviceLocator);
     return $serviceLocator;
 }
开发者ID:paladox,项目名称:mediawiki,代码行数:23,代码来源:MediaWikiTestCase.php


注:本文中的MediaWiki\MediaWikiServices::resetGlobalInstance方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。