本文整理汇总了PHP中wfTime函数的典型用法代码示例。如果您正苦于以下问题:PHP wfTime函数的具体用法?PHP wfTime怎么用?PHP wfTime使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wfTime函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: sendRPC
/**
* @access private
* @static
*/
function sendRPC($method, $params = array())
{
global $mwBlockerHost, $mwBlockerPort, $mwBlockerDebug;
$client = new XML_RPC_Client('/Blocker', $mwBlockerHost, $mwBlockerPort);
if ($mwBlockerDebug) {
$client->debug = true;
}
$rpcParams = array_map(array('MWBlocker', 'outParam'), $params);
$message = new XML_RPC_Message($method, $rpcParams);
wfSuppressWarnings();
$start = wfTime();
$result = $client->send($message);
$delta = wfTime() - $start;
wfRestoreWarnings();
$debug = sprintf("MWBlocker::sendRPC for %s took %0.2fms\n", $method, $delta * 1000.0);
wfDebug($debug);
if ($mwBlockerDebug) {
echo $debug;
}
if (!is_object($result)) {
throw new MWException("Unknown XML-RPC error");
} elseif ($result->faultCode()) {
throw new MWException($result->faultCode() . ': ' . $result->faultString());
} else {
$value = $result->value();
return $value->getval();
}
}
开发者ID:realsoc,项目名称:mediawiki-extensions,代码行数:32,代码来源:MWBlocker.php
示例2: execute
public function execute()
{
if (!($this->hasOption('file') ^ $this->hasOption('dump'))) {
$this->error("You must provide a file or dump", true);
}
$this->checkOptions();
if ($this->hasOption('file')) {
$revision = new WikiRevision();
$revision->setText(file_get_contents($this->getOption('file')));
$revision->setTitle(Title::newFromText(rawurldecode(basename($this->getOption('file'), '.txt'))));
$this->handleRevision($revision);
return;
}
$this->startTime = wfTime();
if ($this->getOption('dump') == '-') {
$source = new ImportStreamSource($this->getStdin());
} else {
$this->error("Sorry, I don't support dump filenames yet. Use - and provide it on stdin on the meantime.", true);
}
$importer = new WikiImporter($source);
$importer->setRevisionCallback(array(&$this, 'handleRevision'));
$this->from = $this->getOption('from', null);
$this->count = 0;
$importer->doImport();
$this->conclusions();
$delta = wfTime() - $this->startTime;
$this->error("Done {$this->count} revisions in " . round($delta, 2) . " seconds ");
if ($delta > 0) {
$this->error(round($this->count / $delta, 2) . " pages/sec");
}
# Perform the memory_get_peak_usage() when all the other data has been output so there's no damage if it dies.
# It is only available since 5.2.0 (since 5.2.1 if you haven't compiled with --enable-memory-limit)
$this->error("Memory peak usage of " . memory_get_peak_usage() . " bytes\n");
}
开发者ID:eFFemeer,项目名称:seizamcore,代码行数:34,代码来源:dumpIterator.php
示例3: testTime
function testTime()
{
$start = wfTime();
$this->assertType('float', $start);
$end = wfTime();
$this->assertTrue($end > $start, "Time is running backwards!");
}
开发者ID:amjadtbssm,项目名称:website,代码行数:7,代码来源:GlobalTest.php
示例4: run
function run()
{
$this->startTime = wfTime();
$file = fopen('php://stdin', 'rt');
$source = new ImportStreamSource($file);
$importer = new WikiImporter($source);
$importer->setRevisionCallback(array(&$this, 'handleRevision'));
return $importer->doImport();
}
开发者ID:BackupTheBerlios,项目名称:shoutwiki-svn,代码行数:9,代码来源:renderDump.php
示例5: execute
public function execute()
{
$this->outputDirectory = $this->getOption('output-dir');
$this->startTime = wfTime();
$source = new ImportStreamSource($this->getStdin());
$importer = new WikiImporter($source);
$importer->setRevisionCallback(array(&$this, 'handleRevision'));
return $importer->doImport();
}
开发者ID:rocLv,项目名称:conference,代码行数:9,代码来源:renderDump.php
示例6: benchHooks
/**
* @param $trials int
* @return string
*/
private function benchHooks($trials = 10)
{
$start = wfTime();
for ($i = 0; $i < $trials; $i++) {
wfRunHooks('Test');
}
$delta = wfTime() - $start;
$pertrial = $delta / $trials;
return sprintf("Took %6.2fs", $pertrial);
}
开发者ID:Tjorriemorrie,项目名称:app,代码行数:14,代码来源:benchmarkHooks.php
示例7: benchSquid
/** @todo document */
function benchSquid($urls, $trials = 1)
{
$start = wfTime();
for ($i = 0; $i < $trials; $i++) {
SquidUpdate::purge($urls);
}
$delta = wfTime() - $start;
$pertrial = $delta / $trials;
$pertitle = $pertrial / count($urls);
return sprintf("%4d titles in %6.2fms (%6.2fms each)", count($urls), $pertrial * 1000.0, $pertitle * 1000.0);
}
开发者ID:BackupTheBerlios,项目名称:shoutwiki-svn,代码行数:12,代码来源:benchmarkPurge.php
示例8: rebuildLocalizationCache
/**
* Update the special pages localization cache
*/
public function rebuildLocalizationCache()
{
global $IP, $wgSpecialPageCacheUpdates, $wgQueryPages, $wgQueryCacheLimit, $wgDisableQueryPageUpdate;
$dbw = wfGetDB(DB_MASTER);
foreach ($wgSpecialPageCacheUpdates as $special => $call) {
if (!is_callable($call)) {
throw new \InvalidArgumentException("Uncallable function '{$call}' for special page {$special}");
}
$start = wfTime();
call_user_func($call, $dbw);
$end = wfTime();
$this->info(sprintf("%-30s completed in %.2fs", $special, $end - $start));
// Wait for the slave to catch up
wfWaitForSlaves();
}
// This is needed to initialise $wgQueryPages
require_once "{$IP}/includes/QueryPage.php";
$disabledPages = $wgDisableQueryPageUpdate ? array_flip($wgDisableQueryPageUpdate) : [];
foreach ($wgQueryPages as $page) {
list($class, $special) = $page;
$limit = isset($page[2]) ? $page[2] : $wgQueryCacheLimit;
$queryPage = $this->getQueryPage($special, $class);
if (array_key_exists($special, $disabledPages)) {
// skip disabled pages
$this->info(sprintf("%-30s disabled", $special));
continue;
}
if (!$queryPage->isExpensive()) {
// don't bother with cheap pages
$this->info(sprintf("%-30s skipped", $special));
continue;
}
$start = wfTime();
$num = $queryPage->recache($limit);
$end = wfTime();
if ($num === false) {
throw new \DBError($dbw, "database error");
}
$this->info(sprintf("%-30s updated %d rows in %.2fs", $special, $num, $end - $start));
if (wfGetLB()->pingAll()) {
// commit the changes if all connections are still open
$dbw->commit();
} else {
// Reopen any connections that have closed
$count = 6;
do {
sleep(10);
} while ($count-- > 0 && !wfGetLB()->pingAll());
}
// Wait for the slave to catch up
wfWaitForSlaves();
}
}
开发者ID:yusufchang,项目名称:app,代码行数:56,代码来源:UpdateSpecialPagesTask.class.php
示例9: progress
function progress($updated)
{
$this->updated += $updated;
$this->processed++;
if ($this->processed % 100 != 0) {
return;
}
$portion = $this->processed / $this->count;
$updateRate = $this->updated / $this->processed;
$now = wfTime();
$delta = $now - $this->startTime;
$estimatedTotalTime = $delta / $portion;
$eta = $this->startTime + $estimatedTotalTime;
printf("%s: %6.2f%% done on %s; ETA %s [%d/%d] %.2f/sec <%.2f%% updated>\n", wfTimestamp(TS_DB, intval($now)), $portion * 100.0, $this->table, wfTimestamp(TS_DB, intval($eta)), $this->processed, $this->count, $this->processed / $delta, $updateRate * 100.0);
flush();
}
开发者ID:BackupTheBerlios,项目名称:shoutwiki-svn,代码行数:16,代码来源:cleanupCaps.php
示例10: execute
public function execute()
{
$dbw = wfGetDB(DB_MASTER);
$test = $dbw->tableName('test');
$dbw->query("CREATE TABLE IF NOT EXISTS /*_*/{$test} (\n test_id int unsigned NOT NULL PRIMARY KEY AUTO_INCREMENT,\n text varbinary(255) NOT NULL\n);");
$this->insertData($dbw);
$start = wfTime();
$this->delete($dbw);
$end = wfTime();
echo "Delete: " . $end - $start;
echo "\r\n";
$this->insertData($dbw);
$start = wfTime();
$this->truncate($dbw);
$end = wfTime();
echo "Truncate: " . $end - $start;
echo "\r\n";
$dbw->dropTable('test');
}
开发者ID:Tjorriemorrie,项目名称:app,代码行数:19,代码来源:bench_delete_truncate.php
示例11: execute
public function execute()
{
$this->outputDirectory = $this->getOption('output-dir');
$this->prefix = $this->getOption('prefix', 'wiki');
$this->startTime = wfTime();
if ($this->hasOption('parser')) {
global $wgParserConf;
$wgParserConf['class'] = $this->getOption('parser');
$this->prefix .= "-{$wgParserConf['class']}";
}
$source = new ImportStreamSource($this->getStdin());
$importer = new WikiImporter($source);
$importer->setRevisionCallback(array(&$this, 'handleRevision'));
$importer->doImport();
$delta = wfTime() - $this->startTime;
$this->error("Rendered {$this->count} pages in " . round($delta, 2) . " seconds ");
if ($delta > 0) {
$this->error(round($this->count / $delta, 2) . " pages/sec");
}
$this->error("\n");
}
开发者ID:eFFemeer,项目名称:seizamcore,代码行数:21,代码来源:renderDump.php
示例12: bench
public function bench(array $benchs)
{
$bench_number = 0;
$count = $this->getOption('count', 100);
foreach ($benchs as $bench) {
// handle empty args
if (!array_key_exists('args', $bench)) {
$bench['args'] = array();
}
$bench_number++;
$start = wfTime();
for ($i = 0; $i < $count; $i++) {
call_user_func_array($bench['function'], $bench['args']);
}
$delta = wfTime() - $start;
// function passed as a callback
if (is_array($bench['function'])) {
$ret = get_class($bench['function'][0]) . '->' . $bench['function'][1];
$bench['function'] = $ret;
}
$this->results[$bench_number] = array('function' => $bench['function'], 'arguments' => $bench['args'], 'count' => $count, 'delta' => $delta, 'average' => $delta / $count);
}
}
开发者ID:GodelDesign,项目名称:Godel,代码行数:23,代码来源:Benchmarker.php
示例13: checkWords
static function checkWords()
{
wfProfileIn(__METHOD__);
$app = F::app();
$request = $app->getGlobal('wgRequest');
// get request params
$lang = $request->getVal('lang', false);
$words = explode(',', $request->getVal('words', ''));
// benchmark
$time = wfTime();
$service = new SpellCheckerService($lang);
$ret = $service->checkWords($words);
// BugId:2570 - log statistics
$wordsCount = count($words);
$suggestionsCount = count($ret['suggestions']);
// finish the benchmark
$time = round(wfTime() - $time, 4);
if (!empty($ret)) {
$ret['info']['time'] = $time;
}
Wikia::log(__METHOD__, __LINE__, "{$wordsCount} words checked / {$suggestionsCount} suggestions / done in {$time} sec.", true);
wfProfileOut(__METHOD__);
return $ret;
}
开发者ID:schwarer2006,项目名称:wikia,代码行数:24,代码来源:SpellCheckerAjax.class.php
示例14: addChunk
/**
* Chunked inserts: perform an insert if we've reached the chunk limit.
* Prints a progress report with estimated completion time.
* @param array &$chunk -- This will be emptied if an insert is done.
* @param int $key A key identifier to use in progress estimation in
* place of the number of rows inserted. Use this if
* you provided a max key number instead of a count
* as the final chunk number in setChunkScale()
* @access private
*/
function addChunk(&$chunk, $key = null)
{
if (count($chunk) >= $this->chunkSize) {
$this->insertChunk($chunk);
$this->chunkCount += count($chunk);
$now = wfTime();
$delta = $now - $this->chunkStartTime;
$rate = $this->chunkCount / $delta;
if (is_null($key)) {
$completed = $this->chunkCount;
} else {
$completed = $key;
}
$portion = $completed / $this->chunkFinal;
$estimatedTotalTime = $delta / $portion;
$eta = $this->chunkStartTime + $estimatedTotalTime;
printf("%s: %6.2f%% done on %s; ETA %s [%d/%d] %.2f/sec\n", wfTimestamp(TS_DB, intval($now)), $portion * 100.0, $this->chunkTable, wfTimestamp(TS_DB, intval($eta)), $completed, $this->chunkFinal, $rate);
flush();
$chunk = array();
}
}
开发者ID:eFFemeer,项目名称:seizamcore,代码行数:31,代码来源:upgrade1_5.php
示例15: updateWSResults
/**
* This method updates cache entries that are used in properties
* that are outdated for a single webservice
*
*/
private function updateWSResults($ws)
{
$log = SGAGardeningIssuesAccess::getGardeningIssuesAccess();
echo "updating " . $ws->getName() . "\n";
$parameterSets = WSStorage::getDatabase()->getWSUsages($ws->getArticleID());
$updatedEntries = 0;
$affectedArticles = array();
foreach ($parameterSets as $parameterSet) {
echo "\t updating paramater set " . $parameterSet["paramSetId"] . "\n";
$cacheResult = WSStorage::getDatabase()->getResultFromCache($ws->getArticleID(), $parameterSet["paramSetId"]);
$refresh = false;
if (count($cacheResult) < 1) {
$refresh = true;
}
if (!$refresh) {
if ($ws->getQueryPolicy() > 0) {
if (wfTime() - wfTimestamp(TS_UNIX, $cacheResult["lastUpdate"]) > $ws->getQueryPolicy() * 60) {
$refresh = true;
}
}
}
if ($refresh) {
echo "\t\t update necessary\n";
if ($updatedEntries > 0) {
sleep($ws->getUpdateDelay());
echo "\t\t sleeping " . $ws->getUpdateDelay() . "\n";
}
$parameters = WSStorage::getDatabase()->getParameters($parameterSet["paramSetId"]);
$parameters = $ws->initializeCallParameters($parameters);
$response = $ws->getWSClient()->call($ws->getMethod(), $parameters);
$goon = true;
if (is_string($response)) {
$log->addGardeningIssueAboutValue($this->id, SMW_GARDISSUE_ERROR_WSCACHE_ENTRIES, Title::newFromText($ws->getName()), 0);
$goon = false;
}
if ($goon) {
WSStorage::getDatabase()->storeCacheEntry($ws->getArticleID(), $parameterSet["paramSetId"], serialize($response), wfTimeStamp(TS_MW, wfTime()), wfTimeStamp(TS_MW, wfTime()));
echo "\t\t update was successfully\n";
//get articles which have to be refreshed
}
}
$tempAffectedArticles = WSStorage::getDatabase()->getUsedWSParameterSetPairs($ws->getArticleID(), $parameterSet["paramSetId"]);
if ($ws->getQueryPolicy() > 0) {
if ($refresh || count($tempAffectedArticles) > 1) {
$affectedArticles = array_merge($affectedArticles, $tempAffectedArticles);
}
$updatedEntries += 1;
}
}
return $affectedArticles;
}
开发者ID:seedbank,项目名称:old-repo,代码行数:56,代码来源:SMW_WSUpdateBot.php
示例16: wfReportTime
/**
* Returns a HTML comment with the elapsed time since request.
* This method has no side effects.
* @return string
*/
function wfReportTime()
{
global $wgRequestTime;
$now = wfTime();
$elapsed = $now - $wgRequestTime;
$com = sprintf("<!-- Served by %s in %01.3f secs. -->", wfHostname(), $elapsed);
return $com;
}
开发者ID:puring0815,项目名称:OpenKore,代码行数:13,代码来源:GlobalFunctions.php
示例17: execute
public function execute()
{
global $wgUseFileCache, $wgDisableCounters, $wgContentNamespaces, $wgRequestTime;
global $wgTitle, $wgArticle, $wgOut, $wgUser;
if (!$wgUseFileCache) {
$this->error("Nothing to do -- \$wgUseFileCache is disabled.", true);
}
$wgDisableCounters = false;
$start = $this->getArg(0, "0");
if (!ctype_digit($start)) {
$this->error("Invalid value for start parameter.", true);
}
$start = intval($start);
$overwrite = $this->hasArg(1) && $this->getArg(1) === 'overwrite';
$this->output("Building content page file cache from page {$start}!\n");
$dbr = wfGetDB(DB_SLAVE);
$start = $start > 0 ? $start : $dbr->selectField('page', 'MIN(page_id)', false, __FUNCTION__);
$end = $dbr->selectField('page', 'MAX(page_id)', false, __FUNCTION__);
if (!$start) {
$this->error("Nothing to do.", true);
}
$_SERVER['HTTP_ACCEPT_ENCODING'] = 'bgzip';
// hack, no real client
OutputPage::setEncodings();
# Not really used yet
# Do remaining chunk
$end += $this->mBatchSize - 1;
$blockStart = $start;
$blockEnd = $start + $this->mBatchSize - 1;
$dbw = wfGetDB(DB_MASTER);
// Go through each page and save the output
while ($blockEnd <= $end) {
// Get the pages
$res = $dbr->select('page', array('page_namespace', 'page_title', 'page_id'), array('page_namespace' => $wgContentNamespaces, "page_id BETWEEN {$blockStart} AND {$blockEnd}"), array('ORDER BY' => 'page_id ASC', 'USE INDEX' => 'PRIMARY'));
foreach ($res as $row) {
$rebuilt = false;
$wgRequestTime = wfTime();
# bug 22852
$wgTitle = Title::makeTitleSafe($row->page_namespace, $row->page_title);
if (null == $wgTitle) {
$this->output("Page {$row->page_id} has bad title\n");
continue;
// broken title?
}
$wgOut->setTitle($wgTitle);
// set display title
$wgUser->getSkin($wgTitle);
// set skin title
$wgArticle = new Article($wgTitle);
// If the article is cacheable, then load it
if ($wgArticle->isFileCacheable()) {
$cache = new HTMLFileCache($wgTitle);
if ($cache->isFileCacheGood()) {
if ($overwrite) {
$rebuilt = true;
} else {
$this->output("Page {$row->page_id} already cached\n");
continue;
// done already!
}
}
ob_start(array(&$cache, 'saveToFileCache'));
// save on ob_end_clean()
$wgUseFileCache = false;
// hack, we don't want $wgArticle fiddling with filecache
$wgArticle->view();
@$wgOut->output();
// header notices
$wgUseFileCache = true;
ob_end_clean();
// clear buffer
$wgOut = new OutputPage();
// empty out any output page garbage
if ($rebuilt) {
$this->output("Re-cached page {$row->page_id}\n");
} else {
$this->output("Cached page {$row->page_id}\n");
}
} else {
$this->output("Page {$row->page_id} not cacheable\n");
}
$dbw->commit();
// commit any changes
}
$blockStart += $this->mBatchSize;
$blockEnd += $this->mBatchSize;
wfWaitForSlaves(5);
}
$this->output("Done!\n");
// Remove these to be safe
if (isset($wgTitle)) {
unset($wgTitle);
}
if (isset($wgArticle)) {
unset($wgArticle);
}
}
开发者ID:GodelDesign,项目名称:Godel,代码行数:97,代码来源:rebuildFileCache.php
示例18: logProfilingData
/**
* @todo document
*/
function logProfilingData()
{
global $wgRequestTime, $wgDebugLogFile, $wgDebugRawPage, $wgRequest;
global $wgProfiling, $wgProfileStack, $wgProfileLimit, $wgUser;
$now = wfTime();
list($usec, $sec) = explode(' ', $wgRequestTime);
$start = (double) $sec + (double) $usec;
$elapsed = $now - $start;
if ($wgProfiling) {
$prof = wfGetProfilingOutput($start, $elapsed);
$forward = '';
if (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
$forward = ' forwarded for ' . $_SERVER['HTTP_X_FORWARDED_FOR'];
}
if (!empty($_SERVER['HTTP_CLIENT_IP'])) {
$forward .= ' client IP ' . $_SERVER['HTTP_CLIENT_IP'];
}
if (!empty($_SERVER['HTTP_FROM'])) {
$forward .= ' from ' . $_SERVER['HTTP_FROM'];
}
if ($forward) {
$forward = "\t(proxied via {$_SERVER['REMOTE_ADDR']}{$forward})";
}
if ($wgUser->isAnon()) {
$forward .= ' anon';
}
$log = sprintf("%s\t%04.3f\t%s\n", gmdate('YmdHis'), $elapsed, urldecode($_SERVER['REQUEST_URI'] . $forward));
if ('' != $wgDebugLogFile && ($wgRequest->getVal('action') != 'raw' || $wgDebugRawPage)) {
error_log($log . $prof, 3, $wgDebugLogFile);
}
}
}
开发者ID:BackupTheBerlios,项目名称:enotifwiki,代码行数:35,代码来源:GlobalFunctions.php
示例19: putToAmazonS3
/**
* Puts the specified file to Amazon S3 storage
*
* if $bPublic, the file will be available for all users
* if $sMimeType is set then the specified mime tipe is set, otherwise
* let AmazonS3 decide on mime type.
*/
public static function putToAmazonS3($sPath, $bPublic = true, $sMimeType = null)
{
$time = wfTime();
$sDestination = wfEscapeShellArg('s3://wikia_xml_dumps/' . DumpsOnDemand::getPath(basename($sPath)));
$sPath = wfEscapeShellArg($sPath);
$sCmd = 'sudo /usr/bin/s3cmd -c /root/.s3cfg --add-header=Content-Disposition:attachment';
if (!is_null($sMimeType)) {
$sMimeType = wfEscapeShellArg($sMimeType);
$sCmd .= " --mime-type={$sMimeType}";
}
$sCmd .= $bPublic ? ' --acl-public' : '';
$sCmd .= " put {$sPath} {$sDestination}";
wfShellExec($sCmd, $iStatus);
$time = Wikia::timeDuration(wfTime() - $time);
Wikia::log(__METHOD__, "info", "Put {$sPath} to Amazon S3 storage: status: {$iStatus}, time: {$time}", true, true);
return $iStatus;
}
开发者ID:Tjorriemorrie,项目名称:app,代码行数:24,代码来源:DumpsOnDemand.php
示例20: create
/**
* main entry point, create wiki with given parameters
*
* @throw CreateWikiException an exception with status of operation set
*/
public function create()
{
global $wgExternalSharedDB, $wgSharedDB, $wgUser;
$then = microtime(true);
// Set this flag to ensure that all select operations go against master
// Slave lag can cause random errors during wiki creation process
global $wgForceMasterDatabase;
$wgForceMasterDatabase = true;
wfProfileIn(__METHOD__);
if (wfReadOnly()) {
wfProfileOut(__METHOD__);
throw new CreateWikiException('DB is read only', self::ERROR_READONLY);
}
// check founder
if ($this->mFounder->isAnon()) {
wfProfileOut(__METHOD__);
throw new CreateWikiException('Founder is anon', self::ERROR_USER_IN_ANON);
}
// check executables
$status = $this->checkExecutables();
if ($status != 0) {
wfProfileOut(__METHOD__);
throw new CreateWikiException('checkExecutables() failed', $status);
}
// check domains
$status = $this->checkDomain();
if ($status != 0) {
wfProfileOut(__METHOD__);
throw new CreateWikiException('Check domain failed', $status);
}
// prepare all values needed for creating wiki
$this->prepareValues();
// prevent domain to be registered more than once
if (!AutoCreateWiki::lockDomain($this->mDomain)) {
wfProfileOut(__METHOD__);
throw new CreateWikiException('Domain name taken', self::ERROR_DOMAIN_NAME_TAKEN);
}
// start counting time
$this->mCurrTime = wfTime();
// check and create database
$this->mDBw = wfGetDB(DB_MASTER, array(), $wgExternalSharedDB);
# central
///
// local database handled is handler to cluster we create new wiki.
// It doesn't have to be the same like wikifactory cluster or db cluster
// where Special:CreateWiki exists.
//
// @todo do not use hardcoded name, code below is only for test
//
// set $activeCluster to false if you want to create wikis on first
// cluster
//
$this->mClusterDB = self::ACTIVE_CLUSTER ? "wikicities_" . self::ACTIVE_CLUSTER : "wikicities";
$this->mNewWiki->dbw = wfGetDB(DB_MASTER, array(), $this->mClusterDB);
// database handler, old $dbwTarget
// check if database is creatable
// @todo move all database creation checkers to canCreateDatabase
if (!$this->canCreateDatabase()) {
wfProfileOut(__METHOD__);
throw new CreateWikiException('DB exists - ' . $this->mNewWiki->dbname, self::ERROR_DATABASE_ALREADY_EXISTS);
} else {
$this->mNewWiki->dbw->query(sprintf("CREATE DATABASE `%s`", $this->mNewWiki->dbname));
wfDebugLog("createwiki", "Database {$this->mNewWiki->dbname} created\n", true);
}
/**
* create position in wiki.factory
* (I like sprintf construction, so sue me)
*/
if (!$this->addToCityList()) {
wfDebugLog("createwiki", __METHOD__ . ": Cannot set data in city_list table\n", true);
wfProfileOut(__METHOD__);
throw new CreateWikiException('Cannot add wiki to city_list', self::ERROR_DATABASE_WRITE_TO_CITY_LIST_BROKEN);
}
// set new city_id
$this->mNewWiki->city_id = $this->mDBw->insertId();
if (empty($this->mNewWiki->city_id)) {
wfProfileOut(__METHOD__);
throw new CreateWikiException('Cannot set data in city_list table. city_id is empty after insert', self::ERROR_DATABASE_WIKI_FACTORY_TABLES_BROKEN);
}
wfDebugLog("createwiki", __METHOD__ . ": Row added added into city_list table, city_id = {$this->mNewWiki->city_id}\n", true);
/**
* add domain and www.domain to the city_domains table
*/
if (!$this->addToCityDomains()) {
wfProfileOut(__METHOD__);
throw new CreateWikiException('Cannot set data in city_domains table', self::ERROR_DATABASE_WRITE_TO_CITY_DOMAINS_BROKEN);
}
wfDebugLog("createwiki", __METHOD__ . ": Row added into city_domains table, city_id = {$this->mNewWiki->city_id}\n", true);
/**
* create image folder
*/
global $wgEnableSwiftFileBackend;
if (empty($wgEnableSwiftFileBackend)) {
wfMkdirParents("{$this->mNewWiki->images_dir}");
wfDebugLog("createwiki", __METHOD__ . ": Folder {$this->mNewWiki->images_dir} created\n", true);
//.........这里部分代码省略.........
开发者ID:Tjorriemorrie,项目名称:app,代码行数:101,代码来源:CreateWiki.php
注:本文中的wfTime函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论