本文整理汇总了PHP中WikiFactory::DomainToID方法的典型用法代码示例。如果您正苦于以下问题:PHP WikiFactory::DomainToID方法的具体用法?PHP WikiFactory::DomainToID怎么用?PHP WikiFactory::DomainToID使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WikiFactory
的用法示例。
在下文中一共展示了WikiFactory::DomainToID方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: execute
public function execute()
{
global $wgRequest, $wgOut, $wgSolrHost, $wgSolrPort, $wgEnableWikiaSearchExt;
if (empty($wgEnableWikiaSearchExt)) {
$wgOut->addHTML("ERROR: WikiaSearch extension is disabled");
return;
}
$params = array();
$query = $wgRequest->getVal('q');
$sort = $wgRequest->getVal('sort');
$params['sort'] = !empty($sort) ? $sort : 'created desc';
$params['fl'] = 'title,url,html,created';
$lang = $wgRequest->getVal('uselang');
if (!empty($lang) && !empty($query)) {
$query .= ' AND lang:' . strtolower($lang);
}
$excludeWikis = $wgRequest->getVal('exclude');
if (!empty($excludeWikis) && !empty($query)) {
$excludeWikis = explode(',', $excludeWikis);
foreach ($excludeWikis as $wikiDomain) {
$wikiId = WikiFactory::DomainToID($wikiDomain);
if (!empty($wikiId)) {
$query .= ' AND !wid:' . $wikiId;
}
}
}
$namespaces = $wgRequest->getVal('ns');
if (!empty($namespaces) && !empty($query)) {
$namespaces = explode(',', $namespaces);
$nsQuery = '';
foreach ($namespaces as $ns) {
$nsQuery .= (!empty($nsQuery) ? ' OR ' : '') . 'ns:' . $ns;
}
$query .= " AND ({$nsQuery})";
}
$limit = $wgRequest->getVal('rows');
$limit = empty($limit) || $limit > 100 ? 15 : $limit;
if (!empty($query)) {
$solr = new Apache_Solr_Service($wgSolrHost, $wgSolrPort, '/solr');
try {
$response = $solr->search($query, 0, $limit, $params);
} catch (Exception $exception) {
$wgOut->addHTML('ERROR: ' . $exception->getMessage());
}
// render template
$oTmpl = new EasyTemplate(dirname(__FILE__) . '/templates');
$oTmpl->set_vars(array('url' => $wgRequest->getFullRequestURL(), 'docs' => !is_null($response->response->docs) ? $response->response->docs : array(), 'dateFormat' => 'D, d M Y H:i:s O'));
$wgRequest->response()->header('Cache-Control: max-age=60');
$wgRequest->response()->header('Content-Type: application/xml');
echo $oTmpl->render('results');
exit;
}
}
示例2: enqueue
/**
* Enqueue a task to rebuild the special pages localization cache
*
* @param string $wikiaDomain The domain name of the wikia in need of a cache rebuild
* @return string Generated task ID for the rebuild task
* @throws \InvalidArgumentException
*/
public function enqueue($wikiaDomain)
{
$wikiaDomain = \Wikia::fixDomainName($wikiaDomain);
$wikiId = \WikiFactory::DomainToID($wikiaDomain);
if (!$wikiId) {
// TODO localize?
throw new \InvalidArgumentException("No wikia exists for domain {$wikiaDomain}");
}
$localizationTask = new UpdateSpecialPagesTask();
$localizationTask->wikiId($wikiId);
$localizationTask->call('rebuildLocalizationCache');
return $localizationTask->queue();
}
示例3: getCityIdByUrl
/**
* Get wiki ID by its url. Handles both "dev.wikia.com" and "dev"
* (in the second pass it appends ".wikia.com" at the end of the supplied value).
*
* @param $url string
* @return int Wiki ID (or null)
*/
protected static function getCityIdByUrl($url)
{
wfProfileIn(__METHOD__);
$id = null;
if ($url === 'dev') {
$id = self::DEV_WIKI_ID;
}
if ($id === null) {
$id = WikiFactory::DomainToID($url);
}
if ($id === null) {
$id = WikiFactory::DomainToID($url . self::WIKIA_DEFAULT_DOMAIN_SUFFIX);
}
wfProfileOut(__METHOD__);
return $id;
}
示例4: array
$positive = array('y', 'Y', 'Yes', 'YES');
$negative = array('n', 'no', 'No', 'NO');
$input = trim($input);
if (in_array($input, $positive)) {
return true;
}
if (in_array($input, $negative)) {
return false;
}
return null;
}
foreach ($list as $wiki) {
echo "\n";
$wiki = sanitizeUrl($wiki);
// get wiki ID
$id = WikiFactory::DomainToID($wiki);
if (empty($id)) {
echo "{$wiki}: ERROR (not found in WikiFactory)\n";
continue;
}
// get URL, in case the one given is not the main one
$oUrl = WikiFactory::getVarByName('wgServer', $id);
$oLang = WikiFactory::getVarByName('wgLanguageCode', $id);
$oSkin = WikiFactory::getVarByName('wgDefaultSkin', $id);
if (empty($oUrl) || empty($oLang)) {
// should never happen, but...
echo "{$wiki}: ERROR (failed to get URL for ID {$id} or language; something's wrong)\n";
continue;
}
$domain = sanitizeUrl(unserialize($oUrl->cv_value));
$lang = unserialize($oLang->cv_value);
示例5: elseif
} elseif (!empty($bydb)) {
Wikia::log('WikiFactory', 'compare', 'detected a bydb, using it');
$to = WikiFactory::DBtoID($bydb);
Wikia::log('WikiFactory', 'compare', 'DBtoID says:' . $to);
if ($to == false) {
Wikia::log('WikiFactory', 'compare', 'found false, failing');
$to = null;
}
} elseif (!empty($byurl)) {
Wikia::log('WikiFactory', 'compare', 'detected a byurl, using it');
if (strpos($byurl, '.') == false) {
Wikia::log('WikiFactory', 'compare', 'no . found in input, adding .wikia.com');
#no
$byurl .= '.wikia.com';
}
$to = WikiFactory::DomainToID($byurl);
Wikia::log('WikiFactory', 'compare', 'DomainToID says:' . $to);
if ($to == false) {
Wikia::log('WikiFactory', 'compare', 'found false, failing');
$to = null;
}
} else {
#no inputs were valid or supplied
}
?>
<fieldset>
<legend>Target Wiki</legend>
<form name="wfCompareFormID" method="get">
<label for="comp-by-id">By ID:</label><input type="text" id="comp-by-id" name="id" size="3" value="<?php
if ($byid) {
print $byid;
示例6: isWikiShared
private function isWikiShared($wikiName)
{
global $wgExternalSharedDB;
$dbr = wfGetDB(DB_SLAVE, array(), $wgExternalSharedDB);
$wikiID = null;
$wikiDomains = ['', '.wikia.com', '.sjc.wikia-inc.com'];
foreach ($wikiDomains as $wikiDomain) {
if (!is_null($wikiID = \WikiFactory::DomainToID($wikiName . $wikiDomain))) {
break;
}
}
if (is_null($wikiID)) {
return [false, null];
}
$isShared = (new \WikiaSQL())->SELECT('city_useshared')->FROM('city_list')->WHERE('city_id')->EQUAL_TO($wikiID)->run($dbr, function ($res) use($wikiID) {
/** @var \ResultWrapper $res */
if ($row = $res->fetchObject()) {
if ($row->city_useshared != '1') {
$this->warning('wiki does not use a shared database, message was not sent', ['wiki_id' => $wikiID]);
return false;
}
}
return true;
});
return [$isShared, $wikiID];
}
示例7: loadDataAndUpdateDatabase
public function loadDataAndUpdateDatabase() {
global $wgCityId;
wfProfileIn(__METHOD__);
if( !$this->options->overwrittenLang ) {
$wikisVisualizationLangCode = WikiFactory::getVarValueByName('wgLanguageCode', $wgCityId);
} else {
$wikisVisualizationLangCode = $this->options->overwrittenLang;
}
echo "\n";
echo 'Uploading wikis for "'.$wikisVisualizationLangCode.'" visualization: ';
echo "\n";
foreach( $this->options->csvContent as $line ) {
$element = str_getcsv($line, ',', '"');
if( $this->areAllRequiredWikiDataForDatabaseSet($element) ) {
$wikiDomain = trim( str_replace('http://', '', $element[2]), '/');
$wikiId = WikiFactory::DomainToID($wikiDomain);
$spreadSheetImageName = basename($element[4]);
$wikiMainImageUrl = $element[4];
$wikiMainImageName = $this->getCorpDestImageName($wikiDomain, $spreadSheetImageName);
$sliderImages = $this->getSliderImages( array_slice($element, self::SPREADSHEET_FIRST_ADD_IMG_IDX, self::SPREADSHEET_LAST_ADD_IMG_IDX) );
$wikiHeadline = !empty($element[1]) ? $element[1] : '';
$wikiDesc = !empty($element[5]) ? $element[5] : wfMsg( 'wikiahome-import-script-no-description' );
if( !$this->options->skipUpload ) {
//upload main image
$this->uploadImage($wikiMainImageUrl, $wikiMainImageName, $wikiId);
//upload slider images
$sliderUploadedImages = $this->uploadSliderImages($wikiDomain, $sliderImages, $wikiId);
}
if( $wikiId > 0 ) {
$wikiCityVertical = HubService::getComscoreCategory($wikiId);
$sliderUploadedImages = (!empty($sliderUploadedImages)) ? json_encode($sliderUploadedImages) : null;
$this->addToVisualizationTable(
array(
'city_id' => $wikiId,
'city_lang_code' => $wikisVisualizationLangCode,
'city_vertical' => $wikiCityVertical,
'city_headline' => $wikiHeadline,
'city_description' => $wikiDesc,
'city_main_image' => $wikiMainImageName,
'city_images' => $sliderUploadedImages,
)
);
} else {
$this->wikisNotAdded[] = $wikiDomain.' ('.$wikiId.') ';
}
}
}
$this->uploadImagesOnWikis();
$this->displayStatus();
wfProfileOut(__METHOD__);
}
示例8: save
public function save()
{
if (!$this->wg->User->isAllowed('gameguidessponsored')) {
$this->displayRestrictionError();
return false;
// skip rendering
}
$this->response->setFormat('json');
$languages = $this->request->getArray('languages');
$err = [];
if (!empty($languages)) {
foreach ($languages as $lang => $videos) {
foreach ($videos as $key => $video) {
$wikiId = (int) WikiFactory::DomainToID($video['wiki_domain']);
$video['wiki_id'] = $wikiId;
$wiki = WikiFactory::getWikiByID($wikiId);
$video['wiki_name'] = $wiki->city_title;
$video['wiki_lang'] = $wiki->city_lang;
$title = Title::newFromText($video['video_name'], NS_FILE);
if (!empty($title) && $title->exists()) {
$vid = wfFindFile($title);
if (!empty($vid) && $vid instanceof WikiaLocalFile) {
$handler = $vid->getHandler();
if ($handler instanceof OoyalaVideoHandler) {
$metadata = $handler->getVideoMetadata(true);
$video['video_id'] = $metadata['videoId'];
$video['duration'] = WikiaFileHelper::formatDuration($metadata['duration']);
$video['video_thumb'] = WikiaFileHelper::getMediaDetail($title)['imageUrl'];
} else {
$err[$video['video_name']] = self::VIDEO_IS_NOT_PROVIDED_BY_OOYALA;
}
} else {
$err[$video['video_name']] = self::VIDEO_DOES_NOT_EXIST;
}
} else {
$err[$video['video_name']] = self::VIDEO_DOES_NOT_EXIST;
}
$videos[$key] = $video;
}
$languages[$lang] = $videos;
}
}
if (!empty($err)) {
$this->response->setVal('error', $err);
} else {
$status = WikiFactory::setVarByName('wgWikiaGameGuidesSponsoredVideos', $this->wg->CityId, $languages);
$this->response->setVal('status', $status);
if ($status) {
wfRunHooks('GameGuidesSponsoredVideosSave');
}
}
return true;
}
示例9: wfDevBoxForceWiki
/**
* Hooks into WikiFactory to force use of the wiki which the developer
* has explicitly set using this panel (if applicable).
*
* @return true to allow the WikiFactoryLoader to do its other necessary initalization.
*/
function wfDevBoxForceWiki(&$wikiFactoryLoader)
{
global $wgDevelEnvironment, $wgWikiFactoryDB, $wgCommandLineMode;
if ($wgDevelEnvironment) {
$forcedWikiDomain = getForcedWikiValue();
$cityId = WikiFactory::DomainToID($forcedWikiDomain);
if (!$cityId) {
// If the overridden name doesn't exist AT ALL, use a default just to let the panel run.
$forcedWikiDomain = DEVBOX_DEFAULT_WIKI_DOMAIN;
$cityId = WikiFactory::DomainToID($forcedWikiDomain);
}
if ($wgCommandLineMode) {
$cityId = getenv("SERVER_ID");
$wikiFactoryLoader->mCityID = $cityId;
$wikiFactoryLoader->mWikiID = $cityId;
}
if ($cityId) {
$wikiFactoryLoader->mServerName = $forcedWikiDomain;
// Need to set both in order to get our desired effects.
$wikiFactoryLoader->mCityID = $cityId;
$wikiFactoryLoader->mWikiID = $cityId;
}
// This section allows us to use c1 or c2 as a source for wiki databases
// Be aware that this means the database has to be loaded in the right cluster according to wikicities!
$db = wfGetDB(DB_SLAVE, "dump", $wgWikiFactoryDB);
$sql = 'SELECT city_cluster from city_list where city_id = ' . $cityId;
$result = $db->query($sql, __METHOD__);
$row = $result->fetchRow();
$wikiFactoryLoader->mVariables["wgDBcluster"] = $row['city_cluster'];
// Final sanity check to make sure our database exists
if ($forcedWikiDomain != DEVBOX_DEFAULT_WIKI_DOMAIN) {
$dbname = WikiFactory::DomainToDB($forcedWikiDomain);
$db1 = wfGetDB(DB_SLAVE, "dump", $wgWikiFactoryDB . '_c1');
$db2 = wfGetDB(DB_SLAVE, "dump", $wgWikiFactoryDB . '_c2');
// lame
$devbox_dbs = array_merge(getDevBoxOverrideDatabases($db1), getDevBoxOverrideDatabases($db2));
if (array_search($dbname, $devbox_dbs) === false) {
echo "<pre>Fatal Error: No local copy of database [{$dbname}] was found.</pre>";
exit;
// fatal error
}
}
// TODO: move this into the config file
global $wgReadOnly;
$wgReadOnly = false;
}
return true;
}
示例10: submitForm
/**
* submitForm()
*
* Tasks with forms execute this method to put params from form to database
*
* @author eloy@wikia
* @access public
*
* @return mixed: true if success, submitted params if error
*/
function submitForm()
{
global $wgRequest, $wgOut;
$iTaskID = $wgRequest->getVal("task-source-task-id");
$sTargetWiki = $wgRequest->getVal("task-target-wiki");
$sTargetWikiID = WikiFactory::DomainToID($sTargetWiki);
if (!is_numeric($iTaskID) || !is_numeric($sTargetWikiID) || is_null($sTargetWikiID)) {
$aFormData = array();
$aFormData["values"] = array("task-source-task-id" => $iTaskID, "task-target-wiki" => $sTargetWiki);
if (!is_numeric($iTaskID)) {
$aFormData["errors"]["task-source-task-id"] = "This field must not be empty and must be integer.";
}
if (!is_numeric($sTargetWikiID) || is_null($sTargetWikiID)) {
$aFormData["errors"]["task-target-wiki"] = "This field must not be empty. Domain must be wiki.factory domain.";
}
return $aFormData;
} else {
$this->createTask(array("source-task-id" => $iTaskID, "target-wiki-id" => $sTargetWikiID));
$wgOut->addHTML(Wikia::successbox("Task added"));
return true;
}
}
示例11: sendMessageToWiki
/**
* sendMessageToWiki
*
* sends a message to specified group of users
*
* @access private
* @author Maciej Błaszkowski (Marooned) <marooned at wikia.com>
*
* @param mixed $params - task arguments
*
* @return boolean: result of sending
*/
private function sendMessageToWiki($params)
{
global $wgExternalSharedDB;
$result = true;
$wikiID = null;
$wikiDomains = array('', '.wikia.com', '.sjc.wikia-inc.com');
foreach ($wikiDomains as $wikiDomain) {
if (!is_null($wikiID = WikiFactory::DomainToID($params['wikiName'] . $wikiDomain))) {
break;
}
}
if (is_null($wikiID)) {
return false;
}
$DB = wfGetDB(DB_SLAVE, array(), $wgExternalSharedDB);
$dbResult = $DB->Query('SELECT city_useshared' . ' FROM city_list' . " WHERE city_id = {$wikiID}" . ';', __METHOD__);
if ($row = $DB->FetchObject($dbResult)) {
if ($row->city_useshared != '1') {
$this->log("Wiki [wiki_id = {$wikiID}] does not use shared database. Message was not sent.");
return false;
}
}
$DB->FreeResult($dbResult);
$wikiDB = WikiFactory::IDtoDB($wikiID);
$this->log("Look into selected wiki for users that belong to a specified group [wiki_id = {$wikiID}, wiki_db = {$wikiDB}]");
$DB = wfGetDB(DB_SLAVE);
$DB->selectDB($wikiDB);
$dbResult = $DB->Query('SELECT ug_user' . ' FROM user_groups' . ' WHERE ug_group = ' . $DB->AddQuotes($params['groupName']) . ';', __METHOD__);
$sqlValues = array();
while ($row = $DB->FetchObject($dbResult)) {
$sqlValues[] = "({$wikiID}, {$row->ug_user}, {$params['messageId']}, " . MSG_STATUS_UNSEEN . ')';
}
$DB->FreeResult($dbResult);
$this->log("Add records about new message to right users [wiki_id = {$wikiID}, wiki_db = {$wikiDB}, number of users = " . count($sqlValues) . "]");
if (count($sqlValues)) {
$result = $this->sendMessageHelperToUsers($sqlValues);
}
unset($sqlValues);
return $result;
}
示例12: sendMessage
private function sendMessage($mSender, $mText, $formData)
{
global $wgExternalSharedDB, $wgStatsDB, $wgUser;
$result = array('msgId' => null, 'errMsg' => null);
$dbInsertResult = false;
$mWikiId = null;
$mLang = $formData['mLang'];
if (is_array($mLang)) {
$mLang = implode(',', $mLang);
}
$mRecipientId = $formData['sendModeUsers'] != 'USER' ? null : $wgUser->idFromName($formData['userName']);
$mWikiName = $formData['wikiName'];
$mRecipientName = $formData['userName'];
$mGroupName = $formData['groupName'] == '' ? $formData['groupNameS'] : $formData['groupName'];
$mSendModeWikis = $formData['sendModeWikis'];
$mSendModeUsers = $formData['sendModeUsers'];
$mHubId = $formData['hubId'];
$mClusterId = $formData['clusterId'];
$mUserNamesArr = array_unique(explode("\n", $formData['listUserNames']));
$mWikiNamesArr = array_unique(explode("\n", $formData['listWikiNames']));
//remove unnecessary data
switch ($mSendModeWikis) {
case 'ALL':
$mWikiName = '';
$mHubId = null;
$mClusterId = null;
break;
case 'HUB':
$mWikiName = '';
$mClusterId = null;
break;
case 'CLUSTER':
$mWikiName = '';
$mHubId = null;
break;
case 'WIKI':
$mHubId = null;
$mClusterId = null;
break;
case 'WIKIS':
$mWikiName = count($mWikiNamesArr) . ' wikis';
$mHubId = null;
$mClusterId = null;
break;
case 'CREATED':
$mWikiName = MSG_WIKI_CREATION_DATE;
$mHubId = null;
$mClusterId = null;
break;
}
switch ($mSendModeUsers) {
case 'ALL':
case 'ACTIVE':
$mRecipientName = '';
$mGroupName = '';
break;
case 'GROUP':
$mRecipientName = '';
break;
case 'USER':
$mGroupName = '';
$mLang = MSG_LANG_ALL;
break;
case 'USERS':
$mRecipientName = count($mUserNamesArr) . ' users';
$mGroupName = '';
$mLang = MSG_LANG_ALL;
break;
case 'ANONS':
$mRecipientName = MSG_RECIPIENT_ANON;
$mGroupName = '';
break;
case 'REGISTRATION':
$mRecipientName = '';
$mGroupName = '';
break;
case 'EDITCOUNT':
$mRecipientName = '';
$mGroupName = '';
break;
}
$sendToAll = $mSendModeWikis == 'ALL' && $mSendModeUsers == 'ALL';
$tmpWikiName = false;
if ($mSendModeWikis == 'WIKI' && $mWikiName != '') {
$tmpWikiName = $mWikiName;
}
if ($tmpWikiName) {
$wikiDomains = array('', '.wikia.com');
foreach ($wikiDomains as $wikiDomain) {
if (!is_null($mWikiId = WikiFactory::DomainToID($tmpWikiName . $wikiDomain))) {
break;
}
}
}
$validDateTime = true;
if ($formData['expireTimeS'] !== '') {
$timestamp = wfTimestamp(TS_UNIX, $formData['expireTimeS']);
if (!$timestamp) {
$validDateTime = false;
}
//.........这里部分代码省略.........
示例13: checkCityIdList
/**
* @desc Parses the source file, retrives city_ids of wikis from the file and checks if given city_id is on the list
* @param String $params city_id or comma-separated city_id list
*/
public function checkCityIdList($params)
{
if (!is_string($params)) {
echo 'Invalid city id or city id list' . "\n";
return false;
}
$isList = strpos($params, ',');
if ($isList) {
$cityIdList = explode(',', $params);
} else {
$cityIdList = array(intval($params));
}
foreach ($this->options->csvContent as $line) {
$element = str_getcsv($line, ',', '"');
if ($this->areAllRequiredWikiDataForDatabaseSet($element)) {
$wikiDomain = trim(str_replace('http://', '', $element[2]), '/');
$wikiId = WikiFactory::DomainToID($wikiDomain);
if (in_array($wikiId, $cityIdList)) {
echo 'Found: ' . $wikiId . ' in the file (' . $wikiDomain . ')' . "\n";
}
}
}
}
示例14: wfDevBoxForceWiki
/**
* Hooks into WikiFactory to force use of the wiki which the developer
* has explicitly set using this panel (if applicable).
*
* @return boolean true to allow the WikiFactoryLoader to do its other necessary initalization.
*/
function wfDevBoxForceWiki(WikiFactoryLoader $wikiFactoryLoader)
{
global $wgDevelEnvironment, $wgExternalSharedDB, $wgCommandLineMode, $wgDevboxDefaultWikiDomain;
if ($wgDevelEnvironment) {
$forcedWikiDomain = getForcedWikiValue();
$cityId = WikiFactory::DomainToID($forcedWikiDomain);
if (!$cityId) {
// If the overridden name doesn't exist AT ALL, use a default just to let the panel run.
$forcedWikiDomain = $wgDevboxDefaultWikiDomain;
$cityId = WikiFactory::DomainToID($forcedWikiDomain);
wfDebug(__METHOD__ . ": domain forced to {$forcedWikiDomain}\n");
}
if ($wgCommandLineMode) {
$cityId = getenv("SERVER_ID");
if (is_numeric($cityId)) {
$wikiFactoryLoader->mCityID = $cityId;
$wikiFactoryLoader->mWikiID = $cityId;
} else {
$dbName = getenv("SERVER_DBNAME");
/**
* find city_id by database name
*/
$dbr = WikiFactory::db(DB_SLAVE);
$cityId = $dbr->selectField("city_list", array("city_id"), array("city_dbname" => $dbName), __METHOD__);
if (is_numeric($cityId)) {
$wikiFactoryLoader->mCityID = $cityId;
$wikiFactoryLoader->mWikiID = $cityId;
}
}
}
if ($cityId) {
$wikiFactoryLoader->mServerName = $forcedWikiDomain;
// Need to set both in order to get our desired effects.
$wikiFactoryLoader->mCityID = $cityId;
$wikiFactoryLoader->mWikiID = $cityId;
}
// This section allows us to use c1 or c2 as a source for wiki databases
// Be aware that this means the database has to be loaded in the right cluster according to wikicities!
$db = WikiFactory::db(DB_SLAVE);
$cluster = $db->selectField('city_list', 'city_cluster', ['city_id' => $cityId], __METHOD__);
$wikiFactoryLoader->mVariables["wgDBcluster"] = $cluster;
// Final sanity check to make sure our database exists
if ($forcedWikiDomain != $wgDevboxDefaultWikiDomain) {
// check if the wiki exist on a cluster
wfDebug(__METHOD__ . ": checking if wiki #{$cityId} exists on {$cluster} cluster...\n");
$dbname = WikiFactory::DomainToDB($forcedWikiDomain);
$db = wfGetDB(DB_MASTER, [], $wgExternalSharedDB . '_' . $cluster);
// force master - @see PLATFORM-528
$res = $db->query('SHOW DATABASES ' . $db->buildLike($dbname), __METHOD__);
// SHOW DATABASES LIKE 'muppet'
if ($res->numRows() === 0) {
header('HTTP/1.1 503');
header('X-Error: missing database');
header('Content-Type: text/plain');
die("No local copy of database [{$dbname}] was found on {$cluster} cluster [using {$db->getServer()} DB].");
}
}
}
return true;
}
示例15: getCityIdByUrl
/**
* Get wiki ID by its url. Handles both "dev.wikia.com" and "dev"
* (in the second pass it appends ".wikia.com" at the end of the supplied value).
*
* @param $url string
* @return int Wiki ID (or null)
*/
protected function getCityIdByUrl($url)
{
$id = null;
if ($url === 'dev') {
$id = self::DEV_WIKI_ID;
}
if ($id === null) {
$id = WikiFactory::DomainToID($url);
}
if ($id === null) {
$id = WikiFactory::DomainToID($url . self::WIKIA_DEFAULT_DOMAIN_SUFFIX);
}
return $id;
}