本文整理汇总了PHP中WikiFactory::getDomainKey方法的典型用法代码示例。如果您正苦于以下问题:PHP WikiFactory::getDomainKey方法的具体用法?PHP WikiFactory::getDomainKey怎么用?PHP WikiFactory::getDomainKey使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WikiFactory
的用法示例。
在下文中一共展示了WikiFactory::getDomainKey方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: execute
/**
* execute
*
* Main entry point for class
*
* @author Krzysztof Krzyżaniak <eloy@wikia-inc.com>
*
* @return integer: wikia id or null if wikia is not handled by WikiFactory
*/
public function execute()
{
wfProfileIn(__METHOD__);
global $wgCityId, $wgDevelEnvironment, $wgDBservers, $wgLBFactoryConf, $wgDBserver, $wgContLang;
/**
* Hook to allow extensions to alter the initialization. For example,
* setting the mCityID then returning true will override which wiki
* to use.
*
* @author Sean Colombo
*/
if (!wfRunHooks('WikiFactory::execute', array(&$this))) {
wfProfileOut(__METHOD__);
return $this->mWikiID;
}
/**
* load balancer uses one method which demand wgContLang defined
* See BugId: 12474
*/
$wgContLang = new StubObject('wgContLang');
/**
* local cache, change to CACHE_ACCEL for local
*/
global $wgWikiFactoryCacheType;
$oMemc = wfGetCache($wgWikiFactoryCacheType);
if (empty($this->mAlwaysFromDB)) {
/**
* remember! for http requests we only known $this->mServerName
* (domain), $this->mCityId is unknown (set to false in constructor)
*/
wfProfileIn(__METHOD__ . "-domaincache");
$key = WikiFactory::getDomainKey($this->mServerName);
$this->mDomain = $oMemc->get($key);
$this->mDomain = isset($this->mDomain["id"]) ? $this->mDomain : array();
$this->debug("reading from cache, key {$key}");
wfProfileOut(__METHOD__ . "-domaincache");
}
if (!isset($this->mDomain["id"]) || $this->mAlwaysFromDB) {
wfProfileIn(__METHOD__ . "-domaindb");
/**
* first run or cache expired
*/
$dbr = $this->getDB();
/**
* interactive/cmdline case. We know city_id so we don't have to
* ask city_domains table
*/
if ($this->mCityID || $this->mCityDB) {
$oRow = $dbr->selectRow(array("city_list"), array("city_id", "city_public", "city_factory_timestamp", "city_url", "city_dbname"), $this->mCityID ? array("city_list.city_id" => $this->mCityID) : array("city_list.city_dbname" => $this->mCityDB), __METHOD__ . '::domaindb');
if (isset($oRow->city_id)) {
preg_match("/http[s]*\\:\\/\\/(.+)\$/", $oRow->city_url, $matches);
$host = rtrim($matches[1], "/");
$this->mCityID = $oRow->city_id;
$this->mWikiID = $oRow->city_id;
$this->mIsWikiaActive = $oRow->city_public;
$this->mCityHost = $host;
$this->mCityDB = $oRow->city_dbname;
$this->mTimestamp = $oRow->city_factory_timestamp;
$this->mDomain = array("id" => $oRow->city_id, "host" => $host, "active" => $oRow->city_public, "time" => $oRow->city_factory_timestamp, "db" => $this->mCityDB);
}
} else {
/**
* request from HTTPD case. We only know server name so we
* have to ask city_domains table
*/
$oRow = $dbr->selectRow(array("city_domains", "city_list"), array("city_list.city_id", "city_public", "city_factory_timestamp", "city_domain", "city_url", "city_dbname"), array("city_domains.city_id = city_list.city_id", "city_domains.city_domain" => $this->mServerName), __METHOD__ . '::servername');
if (isset($oRow->city_id) && $oRow->city_id > 0) {
$oRow->city_domain = strtolower($oRow->city_domain);
preg_match("/http[s]*\\:\\/\\/(.+)\$/", $oRow->city_url, $matches);
$host = rtrim($matches[1], "/");
if ($oRow->city_domain == $this->mServerName && $this->mServerName) {
$this->mWikiID = $oRow->city_id;
$this->mIsWikiaActive = $oRow->city_public;
$this->mCityHost = $host;
$this->mCityDB = $oRow->city_dbname;
$this->mTimestamp = $oRow->city_factory_timestamp;
$this->mDomain = array("id" => $oRow->city_id, "host" => $host, "active" => $oRow->city_public, "time" => $oRow->city_factory_timestamp, "db" => $oRow->city_dbname);
}
}
}
if (empty($this->mAlwaysFromDB) && !empty($this->mWikiID)) {
/**
* store value in cache
*/
$oMemc->set(WikiFactory::getDomainKey($this->mServerName), $this->mDomain, $this->mExpireDomainCacheTimeout);
}
$this->debug("city_id={$this->mWikiID}, reading from database key {$this->mServerName}");
wfProfileOut(__METHOD__ . "-domaindb");
} else {
/**
* data taken from cache
//.........这里部分代码省略.........