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


PHP LBFactory::destroyInstance方法代码示例

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


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

示例1: finalSetup

 /**
  * Handle some last-minute setup here.
  */
 public function finalSetup()
 {
     global $wgCommandLineMode, $wgShowSQLErrors, $wgServer;
     global $wgDBadminuser, $wgDBadminpassword;
     global $wgDBuser, $wgDBpassword, $wgDBservers, $wgLBFactoryConf;
     # Turn off output buffering again, it might have been turned on in the settings files
     if (ob_get_level()) {
         ob_end_flush();
     }
     # Same with these
     $wgCommandLineMode = true;
     # Override $wgServer
     if ($this->hasOption('server')) {
         $wgServer = $this->getOption('server', $wgServer);
     }
     # If these were passed, use them
     if ($this->mDbUser) {
         $wgDBadminuser = $this->mDbUser;
     }
     if ($this->mDbPass) {
         $wgDBadminpassword = $this->mDbPass;
     }
     if ($this->getDbType() == self::DB_ADMIN && isset($wgDBadminuser)) {
         $wgDBuser = $wgDBadminuser;
         $wgDBpassword = $wgDBadminpassword;
         if ($wgDBservers) {
             /**
              * @var $wgDBservers array
              */
             foreach ($wgDBservers as $i => $server) {
                 $wgDBservers[$i]['user'] = $wgDBuser;
                 $wgDBservers[$i]['password'] = $wgDBpassword;
             }
         }
         if (isset($wgLBFactoryConf['serverTemplate'])) {
             $wgLBFactoryConf['serverTemplate']['user'] = $wgDBuser;
             $wgLBFactoryConf['serverTemplate']['password'] = $wgDBpassword;
         }
         LBFactory::destroyInstance();
     }
     $this->afterFinalSetup();
     $wgShowSQLErrors = true;
     @set_time_limit(0);
     $this->adjustMemoryLimit();
 }
开发者ID:nischayn22,项目名称:mediawiki-core,代码行数:48,代码来源:Maintenance.php

示例2: execute


//.........这里部分代码省略.........
     wfRunHooks('WikiFactory::executeBeforeTransferToGlobals', array(&$this));
     /**
      * transfer configuration variables from database to GLOBALS
      */
     if (is_array($this->mVariables)) {
         foreach ($this->mVariables as $key => $value) {
             $tValue = $value;
             #--- check, maybe there are variables in variable
             if (is_string($tValue)) {
                 preg_match_all('/(\\$\\w+)[^\\w]*/', $tValue, $aMatches);
                 if (is_array($aMatches[1])) {
                     foreach ($aMatches[1] as $tKey) {
                         /**
                          * dolar sign in key should be removed
                          * (str_replace is faster than regexp)
                          */
                         $tKeyParsed = str_replace('$', '', $tKey);
                         if (!is_numeric($tKeyParsed)) {
                             #--- replace only if key is not $1, $2 etc.
                             if (array_key_exists($tKeyParsed, $this->mVariables)) {
                                 $tValue = str_replace($tKey, $this->mVariables[$tKeyParsed], $tValue);
                             } else {
                                 if (isset($GLOBALS[$tKeyParsed])) {
                                     $tValue = str_replace($tKey, $GLOBALS[$tKeyParsed], $tValue);
                                 }
                             }
                         }
                     }
                 }
             }
             /**
              * merge local values with global
              */
             switch ($key) {
                 case "wgNamespacesWithSubpagesLocal":
                     $this->LocalToGlobalArray($tValue, $GLOBALS["wgNamespacesWithSubpages"]);
                     break;
                 case "wgExtraNamespacesLocal":
                     $this->LocalToGlobalArray($tValue, $GLOBALS["wgExtraNamespaces"]);
                     break;
                 case "wgFileExtensionsLocal":
                     $this->LocalToGlobalArray($tValue, $GLOBALS["wgFileExtensions"], true);
                     break;
                 case "wgTrustedMediaFormatsLocal":
                     $this->LocalToGlobalArray($tValue, $GLOBALS["wgTrustedMediaFormats"]);
                     break;
                 case "wgFileBlacklistLocal":
                     $this->LocalToGlobalArray($tValue, $GLOBALS["wgFileBlacklist"]);
                     break;
             }
             if ($key == 'wgServer') {
                 $headers = Wikia::getAllHeaders();
                 if (array_key_exists('X-Original-Host', $headers) && !empty($headers['X-Original-Host'])) {
                     global $wgConf;
                     $tValue = 'http://' . $headers['X-Original-Host'];
                     $wgConf->localVHosts = array_merge($wgConf->localVHosts, array($headers['X-Original-Host']));
                 }
             }
             try {
                 if ($this->mSaveDefaults) {
                     $GLOBALS['wgPreWikiFactoryValues'][$key] = $tValue;
                 }
                 $GLOBALS[$key] = $tValue;
             } catch (Exception $e) {
                 #--- so far do nothing
             }
         }
     }
     $wgCityId = $this->mWikiID;
     /**
      * set/replace $wgDBname in $wgDBservers
      */
     if (isset($wgDBservers) && is_array($wgDBservers) && isset($this->mVariables["wgDBname"])) {
         foreach ($wgDBservers as $index => $server) {
             $wgDBservers[$index]["dbname"] = $this->mVariables["wgDBname"];
         }
     }
     if (isset($wgLBFactoryConf) && is_array($wgLBFactoryConf) && isset($this->mVariables["wgDBname"])) {
         $wgLBFactoryConf['serverTemplate']['dbname'] = $this->mVariables["wgDBname"];
         /**
          * set wgDBserver for cluster based on $wgLBFactoryConf
          */
         $cluster = isset($this->mVariables["wgDBcluster"]) ? $this->mVariables["wgDBcluster"] : "DEFAULT";
         if (isset($wgLBFactoryConf["sectionLoads"][$cluster])) {
             $keys = array_keys($wgLBFactoryConf["sectionLoads"][$cluster]);
             $db = array_shift($keys);
             if (isset($wgLBFactoryConf["hostsByName"][$db])) {
                 $wgDBserver = $wgLBFactoryConf["hostsByName"][$db];
                 $this->debug("wgDBserver for cluster {$cluster} set to {$wgDBserver}");
             }
         }
     }
     wfRunHooks('WikiFactory::onExecuteComplete', array(&$this));
     wfProfileOut(__METHOD__);
     /**
      * cleanup and finally return wiki id
      */
     LBFactory::destroyInstance();
     return $this->mWikiID;
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:101,代码来源:WikiFactoryLoader.php

示例3: finalSetup

 /**
  * Handle some last-minute setup here.
  */
 public function finalSetup()
 {
     global $wgCommandLineMode, $wgShowSQLErrors, $wgServer;
     global $wgDBadminuser, $wgDBadminpassword;
     global $wgDBuser, $wgDBpassword, $wgDBservers, $wgLBFactoryConf;
     # Turn off output buffering again, it might have been turned on in the settings files
     if (ob_get_level()) {
         ob_end_flush();
     }
     # Same with these
     $wgCommandLineMode = true;
     # Override $wgServer
     if ($this->hasOption('server')) {
         $wgServer = $this->getOption('server', $wgServer);
     }
     # If these were passed, use them
     if ($this->mDbUser) {
         $wgDBadminuser = $this->mDbUser;
     }
     if ($this->mDbPass) {
         $wgDBadminpassword = $this->mDbPass;
     }
     if ($this->getDbType() == self::DB_ADMIN && isset($wgDBadminuser)) {
         $wgDBuser = $wgDBadminuser;
         $wgDBpassword = $wgDBadminpassword;
         if ($wgDBservers) {
             /**
              * @var $wgDBservers array
              */
             foreach ($wgDBservers as $i => $server) {
                 $wgDBservers[$i]['user'] = $wgDBuser;
                 $wgDBservers[$i]['password'] = $wgDBpassword;
             }
         }
         if (isset($wgLBFactoryConf['serverTemplate'])) {
             $wgLBFactoryConf['serverTemplate']['user'] = $wgDBuser;
             $wgLBFactoryConf['serverTemplate']['password'] = $wgDBpassword;
         }
         LBFactory::destroyInstance();
     }
     $this->afterFinalSetup();
     $wgShowSQLErrors = true;
     // @codingStandardsIgnoreStart Allow error supppression. wfSuppressWarnings()
     // is not avaiable.
     @set_time_limit(0);
     // @codingStandardsIgnoreStart
     $this->adjustMemoryLimit();
     // Per-script profiling; useful for debugging
     $forcedProfiler = $this->getOption('profiler');
     if ($forcedProfiler === 'text') {
         Profiler::setInstance(new ProfilerSimpleText(array()));
         Profiler::instance()->setTemplated(true);
     } elseif ($forcedProfiler === 'trace') {
         Profiler::setInstance(new ProfilerSimpleTrace(array()));
         Profiler::instance()->setTemplated(true);
     }
 }
开发者ID:whysasse,项目名称:kmwiki,代码行数:60,代码来源:Maintenance.php

示例4: scriptDone

 private function scriptDone($script)
 {
     global $wgDBuser, $wgDBpassword, $wgDBadminuser, $wgDBadminpassword, $wgDBuserold, $wgDBpasswordold;
     if ($script->getDbType() === Maintenance::DB_ADMIN && isset($wgDBadminuser)) {
         $wgDBuser = $wgDBuserold;
         $wgDBpassword = $wgDBpasswordold;
         unset($GLOBALS['wgDBuserold'], $GLOBALS['wgDBpasswordold']);
         LBFactory::destroyInstance();
     }
     $goptions = $this->metadata[$this->type]['option'];
     $gargs = $this->metadata[$this->type]['arg'];
     if ($goptions != array()) {
         foreach ($goptions as $a) {
             if ($a['type'] == 'textarea' && $a['tmpfile'] && file_exists($a['tmpfile'])) {
                 unlink($a['tmpfile']);
             }
         }
     }
     if ($gargs != array()) {
         foreach ($gargs as $a) {
             if ($a['type'] == 'textarea' && $a['tmpfile'] && file_exists($a['tmpfile'])) {
                 unlink($a['tmpfile']);
             }
         }
     }
 }
开发者ID:yusufchang,项目名称:app,代码行数:26,代码来源:Maintenance_body.php

示例5: tearDown

 function tearDown()
 {
     LBFactory::destroyInstance();
 }
开发者ID:amjadtbssm,项目名称:website,代码行数:4,代码来源:SearchUpdateTest.php

示例6: exportGroup

 protected function exportGroup(MessageGroup $group, $multi = false)
 {
     // Make sure all existing connections are dead,
     // we can't use them in forked children.
     LBFactory::destroyInstance();
     $server = TTMServer::primary();
     $id = $group->getId();
     $sourceLanguage = $group->getSourceLanguage();
     if ($multi) {
         $stats = MessageGroupStats::forGroup($id);
         $this->statusLine("Loaded stats for {$id}\n");
     } else {
         $this->statusLine("Loading stats... ", 4);
         $stats = MessageGroupStats::forGroup($id);
         $this->output("done!", 4);
         $this->statusLine("Inserting sources: ", 5);
     }
     $collection = $group->initCollection($sourceLanguage);
     $collection->filter('ignored');
     $collection->filter('optional');
     $collection->initMessages();
     $sids = array();
     $counter = 0;
     foreach ($collection->keys() as $mkey => $title) {
         $def = $collection[$mkey]->definition();
         $sids[$mkey] = $server->insertSource($title, $sourceLanguage, $def);
         if (++$counter % $this->mBatchSize === 0 && !$multi) {
             wfWaitForSlaves(10);
             $this->output('.', 5);
         }
     }
     $total = count($sids);
     if ($multi) {
         $this->statusLine("Inserted {$total} source entries for {$id}\n");
     } else {
         $this->output("{$total} entries", 5);
         $this->statusLine("Inserting translations...", 6);
     }
     $dbw = $server->getDB(DB_MASTER);
     foreach ($stats as $targetLanguage => $numbers) {
         if ($targetLanguage === $sourceLanguage) {
             continue;
         }
         if ($numbers[MessageGroupStats::TRANSLATED] === 0) {
             continue;
         }
         if (!$multi) {
             $this->output(sprintf("%19s  ", $targetLanguage), $targetLanguage);
         }
         $collection->resetForNewLanguage($targetLanguage);
         $collection->filter('ignored');
         $collection->filter('optional');
         $collection->filter('translated', false);
         $collection->loadTranslations();
         $inserts = array();
         foreach ($collection->keys() as $mkey => $title) {
             $inserts[] = array('tmt_sid' => $sids[$mkey], 'tmt_lang' => $targetLanguage, 'tmt_text' => $collection[$mkey]->translation());
         }
         do {
             $batch = array_splice($inserts, 0, $this->mBatchSize);
             $dbw->insert('translate_tmt', $batch, __METHOD__);
             if (!$multi) {
                 $this->output('.', $targetLanguage);
             }
             wfWaitForSlaves(10);
         } while (count($inserts));
     }
     if ($multi) {
         $this->statusLine("Inserted translations for {$id}\n");
     }
 }
开发者ID:schwarer2006,项目名称:wikia,代码行数:71,代码来源:ttmserver-export.php

示例7: resetStateForFork

 protected function resetStateForFork()
 {
     // Child, reseed because there is no bug in PHP:
     // http://bugs.php.net/bug.php?id=42465
     mt_srand(getmypid());
     // Make sure all existing connections are dead,
     // we can't use them in forked children.
     LBFactory::destroyInstance();
 }
开发者ID:HuijiWiki,项目名称:mediawiki-extensions-Translate,代码行数:9,代码来源:ttmserver-export.php


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