本文整理汇总了PHP中WikiFactory::getVarsKey方法的典型用法代码示例。如果您正苦于以下问题:PHP WikiFactory::getVarsKey方法的具体用法?PHP WikiFactory::getVarsKey怎么用?PHP WikiFactory::getVarsKey使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WikiFactory
的用法示例。
在下文中一共展示了WikiFactory::getVarsKey方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: execute
//.........这里部分代码省略.........
if (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
$ips = preg_split('/\\s*,\\s*/', $_SERVER['HTTP_X_FORWARDED_FOR']);
}
if (!empty($_SERVER['REMOTE_ADDR'])) {
$ips[] = $_SERVER['REMOTE_ADDR'];
}
if (!empty($ips[0])) {
require_once 'Net/GeoIP.php';
try {
$geoip = Net_GeoIP::getInstance($wgLocationOfGeoIPDatabase);
if ('GB' == $geoip->lookupCountryCode($ips[0])) {
header("X-Redirected-By-WF: Geo");
/**
* just exit, no redirect at all
*/
wfProfileOut(__METHOD__);
exit(0);
}
} catch (Exception $e) {
#--- ignore exception, redirect is an option, not a necessity
}
}
}
}
/**
* get info about city variables from memcached and then check,
* maybe memcached is down and returned only error code
*/
if (empty($this->mAlwaysFromDB)) {
wfProfileIn(__METHOD__ . "-varscache");
/**
* first from serialized file
*/
$key = WikiFactory::getVarsKey($this->mWikiID);
$data = $oMemc->get($key);
if (isset($data["stamp"]) && $data["stamp"] == $this->mTimestamp) {
$this->mVariables = isset($data["data"]) && is_array($data["data"]) ? $data["data"] : array();
$this->debug("wikifactory: reading from cache, key {$key}, count " . count($this->mVariables));
} else {
$this->debug("wikifactory: timestamp doesn't match. Cache expired");
}
wfProfileOut(__METHOD__ . "-varscache");
}
/**
* if wgDBname is not defined we get all variables from database
*/
if (!isset($this->mVariables["wgDBname"])) {
wfProfileIn(__METHOD__ . "-varsdb");
$dbr = $this->getDB();
$oRes = $dbr->select(array("city_variables", "city_variables_pool"), array("cv_name", "cv_value"), array("cv_id = cv_variable_id", "cv_city_id = {$this->mWikiID}"), __METHOD__ . '::varsdb');
while ($oRow = $dbr->fetchObject($oRes)) {
#--- some magic, rewritting path, etc legacy data
global $_variable_key, $_variable_value;
set_error_handler("wfUnserializeHandler");
$_variable_key = $oRow->cv_name;
$_variable_value = $oRow->cv_value;
$tUnserVal = unserialize($oRow->cv_value);
restore_error_handler();
if (!empty($wgDevelEnvironment) && $oRow->cv_name === "wgServer") {
/**
* skip this variable
*/
unset($this->mVariables[$oRow->cv_name]);
$this->debug("{$oRow->cv_name} with value {$tUnserVal} skipped");
} else {
$this->mVariables[$oRow->cv_name] = $tUnserVal;
示例2: ini_set
<?php
ini_set("include_path", dirname(__FILE__) . "/..");
$IP = $GLOBALS["IP"];
require_once "commandLine.inc";
$dbr = wfGetDB(DB_SLAVE, 'stats', $wgExternalSharedDB);
$dbw = wfGetDB(DB_MASTER, array(), $wgStatsDB);
for ($i = 1; $i < 140000; $i++) {
global $wgMemc;
echo "recover {$i} \n";
$key = WikiFactory::getVarsKey($i);
$data = $wgMemc->get($key);
if (!empty($data)) {
$records = $data["data"] && is_array($data["data"]) ? $data["data"] : array();
if (!empty($records)) {
echo count($records) . " records found \n";
if (count($records)) {
$dbw->insert("recover", array("id" => $i, "data" => serialize($records)));
}
} else {
echo "no data found (2) \n";
}
} else {
echo "no data found \n";
}
}
示例3: execute
/**
* execute
*
* entry point for TaskExecutor
*
* @access public
* @author eloy@wikia
*
* @param mixed $params default null - task data from wikia_tasks table
*
* @return boolean - status of operation
*/
public function execute($params = null)
{
global $IP, $wgWikiaLocalSettingsPath, $wgWikiaAdminSettingsPath, $wgExtensionMessagesFiles;
$this->mTaskID = $params->task_id;
$this->mParams = unserialize($params->task_arguments);
$city_id = $this->mParams["city_id"];
$command = $this->mParams["command"];
$type = $this->mParams["type"];
$server = $this->mParams["server"];
$this->addLog("wgServer for this site is: {$server}");
if ($city_id && $command) {
$this->mWikiId = $city_id;
/**
* execute maintenance script
*/
$cmd = sprintf("SERVER_ID={$city_id} php {$IP}/{$command} --server={$server} --conf {$wgWikiaLocalSettingsPath} --aconf {$wgWikiaAdminSettingsPath}");
$this->addLog("Running {$cmd}");
$retval = wfShellExec($cmd, $status);
$this->addLog($retval);
if ($type == "ACWLocal" || $type == "CWLocal") {
$cmd = sprintf("SERVER_ID={$city_id} php {$IP}/maintenance/update.php --server={$server} --quick --nopurge --conf {$wgWikiaLocalSettingsPath} --aconf {$wgWikiaAdminSettingsPath}");
$this->addLog("Running {$cmd}");
$retval = wfShellExec($cmd, $status);
$this->addLog($retval);
$cmd = sprintf("SERVER_ID={$city_id} php {$IP}/maintenance/initStats.php --server={$server} --conf {$wgWikiaLocalSettingsPath} --aconf {$wgWikiaAdminSettingsPath}");
$this->addLog("Running {$cmd}");
$retval = wfShellExec($cmd, $status);
$this->addLog($retval);
$cmd = sprintf("SERVER_ID={$city_id} php {$IP}/maintenance/refreshLinks.php --server={$server} --new-only --conf {$wgWikiaLocalSettingsPath} --aconf {$wgWikiaAdminSettingsPath}");
$this->addLog("Running {$cmd}");
$retval = wfShellExec($cmd, $status);
$this->addLog($retval);
$this->addLog("Remove edit lock");
$oVariable = WikiFactory::getVarByName('wgReadOnly', $city_id);
if (isset($oVariable->cv_variable_id)) {
WikiFactory::removeVarById($oVariable->cv_variable_id, $city_id);
WikiFactory::clearCache($city_id);
}
}
$dbname = WikiFactory::IDtoDB($city_id);
$cmd = sprintf("perl /usr/wikia/backend/bin/scribe/events_local_users.pl --usedb={$dbname} ");
$this->addLog("Running {$cmd}");
$retval = wfShellExec($cmd, $status);
$this->addLog($retval);
/**
* once again clear cache at the very end
*/
$wgMemc = wfGetMainCache();
$wgMemc->delete(WikiFactory::getVarsKey($city_id));
}
return true;
}
示例4: maintenance
public function maintenance($server)
{
global $wgCityId, $IP;
$cmd = sprintf("SERVER_ID={$wgCityId} php {$IP}/maintenance/update.php --server={$server} --quick --nopurge");
$output = wfShellExec($cmd, $exitStatus);
$this->info('run update.php', ['exitStatus' => $exitStatus, 'output' => $output]);
$cmd = sprintf("SERVER_ID={$wgCityId} php {$IP}/maintenance/initStats.php --server={$server}");
$output = wfShellExec($cmd, $exitStatus);
$this->info('run initStats.php', ['exitStatus' => $exitStatus, 'output' => $output]);
$cmd = sprintf("SERVER_ID={$wgCityId} php {$IP}/maintenance/refreshLinks.php --server={$server} --new-only");
$output = wfShellExec($cmd, $exitStatus);
$this->info('run refreshLinks.php', ['exitStatus' => $exitStatus, 'output' => $output]);
$this->info("Remove edit lock");
$variable = \WikiFactory::getVarByName('wgReadOnly', $wgCityId);
if (isset($variable->cv_variable_id)) {
\WikiFactory::removeVarById($variable->cv_variable_id, $wgCityId);
\WikiFactory::clearCache($wgCityId);
}
$dbname = \WikiFactory::IDtoDB($wgCityId);
$founder = $this->founder->getId();
$cmd = sprintf("perl /usr/wikia/backend/bin/scribe/events_local_users.pl --usedb={$dbname} --user={$founder} ");
$output = wfShellExec($cmd, $exitStatus);
$this->info('run events_local_users.pl', ['exitStatus' => $exitStatus, 'output' => $output]);
$wgMemc = wfGetMainCache();
$wgMemc->delete(\WikiFactory::getVarsKey($wgCityId));
return true;
}
示例5: die
/**
* Maintenance script for syncing events_local_users table (ListUsers)
* Usage: php syncListUsers.php --wiki_id=12345
*/
require_once '../commandLine.inc';
$usage = "Usage: php syncListUsers.php --wiki_id=12345\n";
if (!isset($options['wiki_id']) || isset($options['wiki_id']) && !is_numeric($options['wiki_id'])) {
die("Error: Invalid format.\n" . $usage);
}
if (!empty($wgDevelEnvironment)) {
die("Sorry. production only.\n");
}
$wiki_id = $options['wiki_id'];
$wiki = WikiFactory::getWikiById($wiki_id);
if (!$wiki) {
die("Wiki {$wiki_id} not found.\n");
}
// update events_local_users
$dbname = $wiki->city_dbname;
echo "Wiki: id={$wiki_id}, dbname={$dbname}\n";
$cmd = sprintf("perl /usr/wikia/backend/bin/scribe/events_local_users.pl --usedb={$dbname} ");
echo "Running {$cmd}\n";
$retval = wfShellExec($cmd, $status);
echo "{$retval}\n";
// clear cache
$wgMemc = wfGetMainCache();
$memKey = WikiFactory::getVarsKey($wiki_id);
echo "Clearing cache ({$memKey}).\n";
$wgMemc->delete($memKey);
echo "Successfully update list users (events_local_users table).\n";