本文整理汇总了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();
}
示例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;
}
示例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);
}
}
示例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']);
}
}
}
}
示例5: tearDown
function tearDown()
{
LBFactory::destroyInstance();
}
示例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");
}
}
示例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();
}