本文整理汇总了PHP中wfHostname函数的典型用法代码示例。如果您正苦于以下问题:PHP wfHostname函数的具体用法?PHP wfHostname怎么用?PHP wfHostname使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wfHostname函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
function __construct($key, $archive = 0)
{
$this->app = F::app();
switch ($key) {
case 'edit':
$this->mKey = self::EDIT_CATEGORY;
$this->mEventType = self::EDIT_CATEGORY_INT;
break;
case 'create':
$this->mKey = self::CREATEPAGE_CATEGORY;
$this->mEventType = self::CREATEPAGE_CATEGORY_INT;
break;
case 'delete':
$this->mKey = self::DELETE_CATEGORY;
$this->mEventType = self::DELETE_CATEGORY_INT;
break;
case 'undelete':
$this->mKey = self::UNDELETE_CATEGORY;
$this->mEventType = self::UNDELETE_CATEGORY_INT;
break;
}
$this->setCityId($this->app->wg->CityId);
$this->setServerName($this->app->wg->Server);
$this->setIp($this->app->wg->Request->getIP());
$this->setHostname(wfHostname());
$this->setBeaconId(wfGetBeaconId());
$this->setArchive($archive);
$this->setLanguage();
$this->setCategory();
}
示例2: log
public function log(array $stats)
{
$pfhost = $this->perHost ? wfHostname() : '';
try {
$dbw = wfGetDB(DB_MASTER);
$useTrx = $dbw->getType() === 'sqlite';
// much faster
if ($useTrx) {
$dbw->startAtomic(__METHOD__);
}
foreach ($stats as $data) {
$name = $data['name'];
$eventCount = $data['calls'];
$timeSum = (double) $data['real'];
$memorySum = (double) $data['memory'];
$name = substr($name, 0, 255);
// Kludge
$timeSum = $timeSum >= 0 ? $timeSum : 0;
$memorySum = $memorySum >= 0 ? $memorySum : 0;
$dbw->upsert('profiling', array('pf_name' => $name, 'pf_count' => $eventCount, 'pf_time' => $timeSum, 'pf_memory' => $memorySum, 'pf_server' => $pfhost), array(array('pf_name', 'pf_server')), array("pf_count=pf_count+{$eventCount}", "pf_time=pf_time+{$timeSum}", "pf_memory=pf_memory+{$memorySum}"), __METHOD__);
}
if ($useTrx) {
$dbw->endAtomic(__METHOD__);
}
} catch (DBError $e) {
}
}
示例3: doTransform
function doTransform($image, $dstPath, $dstUrl, $params, $flags = 0)
{
global $wgSVGConverters, $wgSVGConverter, $wgSVGConverterPath;
if (!$this->normaliseParams($image, $params)) {
return new TransformParameterError($params);
}
$clientWidth = $params['width'];
$clientHeight = $params['height'];
$physicalWidth = $params['physicalWidth'];
$physicalHeight = $params['physicalHeight'];
$srcPath = $image->getPath();
if ($flags & self::TRANSFORM_LATER) {
return new ThumbnailImage($image, $dstUrl, $clientWidth, $clientHeight, $dstPath);
}
if (!wfMkdirParents(dirname($dstPath))) {
return new MediaTransformError('thumbnail_error', $clientWidth, $clientHeight, wfMsg('thumbnail_dest_directory'));
}
$err = false;
if (isset($wgSVGConverters[$wgSVGConverter])) {
$cmd = str_replace(array('$path/', '$width', '$height', '$input', '$output'), array($wgSVGConverterPath ? wfEscapeShellArg("{$wgSVGConverterPath}/") : "", intval($physicalWidth), intval($physicalHeight), wfEscapeShellArg($srcPath), wfEscapeShellArg($dstPath)), $wgSVGConverters[$wgSVGConverter]) . " 2>&1";
wfProfileIn('rsvg');
wfDebug(__METHOD__ . ": {$cmd}\n");
$err = wfShellExec($cmd, $retval);
wfProfileOut('rsvg');
}
$removed = $this->removeBadFile($dstPath, $retval);
if ($retval != 0 || $removed) {
wfDebugLog('thumbnail', sprintf('thumbnail failed on %s: error %d "%s" from "%s"', wfHostname(), $retval, trim($err), $cmd));
return new MediaTransformError('thumbnail_error', $clientWidth, $clientHeight, $err);
} else {
return new ThumbnailImage($image, $dstUrl, $clientWidth, $clientHeight, $dstPath);
}
}
示例4: logToFile
function logToFile($msg, $file)
{
$header = '[' . date('d\\TH:i:s') . '] ' . wfHostname() . ' ' . posix_getpid();
if ($this->slaveId !== false) {
$header .= "({$this->slaveId})";
}
$header .= ' ' . wfWikiID();
wfErrorLog(sprintf("%-50s %s\n", $header, $msg), $file);
}
示例5: applyDefaultConfig
/**
* @param array $lbConf Config for LBFactory::__construct()
* @param Config $mainConfig Main config object from MediaWikiServices
* @return array
*/
public static function applyDefaultConfig(array $lbConf, Config $mainConfig)
{
global $wgCommandLineMode;
$lbConf += ['localDomain' => new DatabaseDomain($mainConfig->get('DBname'), null, $mainConfig->get('DBprefix')), 'profiler' => Profiler::instance(), 'trxProfiler' => Profiler::instance()->getTransactionProfiler(), 'replLogger' => LoggerFactory::getInstance('DBReplication'), 'queryLogger' => LoggerFactory::getInstance('DBQuery'), 'connLogger' => LoggerFactory::getInstance('DBConnection'), 'perfLogger' => LoggerFactory::getInstance('DBPerformance'), 'errorLogger' => [MWExceptionHandler::class, 'logException'], 'cliMode' => $wgCommandLineMode, 'hostname' => wfHostname(), 'readOnlyReason' => wfConfiguredReadOnlyReason()];
if ($lbConf['class'] === 'LBFactorySimple') {
if (isset($lbConf['servers'])) {
// Server array is already explicitly configured; leave alone
} elseif (is_array($mainConfig->get('DBservers'))) {
foreach ($mainConfig->get('DBservers') as $i => $server) {
if ($server['type'] === 'sqlite') {
$server += ['dbDirectory' => $mainConfig->get('SQLiteDataDir')];
} elseif ($server['type'] === 'postgres') {
$server += ['port' => $mainConfig->get('DBport')];
}
$lbConf['servers'][$i] = $server + ['schema' => $mainConfig->get('DBmwschema'), 'tablePrefix' => $mainConfig->get('DBprefix'), 'flags' => DBO_DEFAULT, 'sqlMode' => $mainConfig->get('SQLMode'), 'utf8Mode' => $mainConfig->get('DBmysql5')];
}
} else {
$flags = DBO_DEFAULT;
$flags |= $mainConfig->get('DebugDumpSql') ? DBO_DEBUG : 0;
$flags |= $mainConfig->get('DBssl') ? DBO_SSL : 0;
$flags |= $mainConfig->get('DBcompress') ? DBO_COMPRESS : 0;
$server = ['host' => $mainConfig->get('DBserver'), 'user' => $mainConfig->get('DBuser'), 'password' => $mainConfig->get('DBpassword'), 'dbname' => $mainConfig->get('DBname'), 'schema' => $mainConfig->get('DBmwschema'), 'tablePrefix' => $mainConfig->get('DBprefix'), 'type' => $mainConfig->get('DBtype'), 'load' => 1, 'flags' => $flags, 'sqlMode' => $mainConfig->get('SQLMode'), 'utf8Mode' => $mainConfig->get('DBmysql5')];
if ($server['type'] === 'sqlite') {
$server['dbDirectory'] = $mainConfig->get('SQLiteDataDir');
} elseif ($server['type'] === 'postgres') {
$server['port'] = $mainConfig->get('DBport');
}
$lbConf['servers'] = [$server];
}
if (!isset($lbConf['externalClusters'])) {
$lbConf['externalClusters'] = $mainConfig->get('ExternalServers');
}
} elseif ($lbConf['class'] === 'LBFactoryMulti') {
if (isset($lbConf['serverTemplate'])) {
$lbConf['serverTemplate']['schema'] = $mainConfig->get('DBmwschema');
$lbConf['serverTemplate']['sqlMode'] = $mainConfig->get('SQLMode');
$lbConf['serverTemplate']['utf8Mode'] = $mainConfig->get('DBmysql5');
}
}
// Use APC/memcached style caching, but avoids loops with CACHE_DB (T141804)
$sCache = MediaWikiServices::getInstance()->getLocalServerObjectCache();
if ($sCache->getQoS($sCache::ATTR_EMULATION) > $sCache::QOS_EMULATION_SQL) {
$lbConf['srvCache'] = $sCache;
}
$cCache = ObjectCache::getLocalClusterInstance();
if ($cCache->getQoS($cCache::ATTR_EMULATION) > $cCache::QOS_EMULATION_SQL) {
$lbConf['memCache'] = $cCache;
}
$wCache = MediaWikiServices::getInstance()->getMainWANObjectCache();
if ($wCache->getQoS($wCache::ATTR_EMULATION) > $wCache::QOS_EMULATION_SQL) {
$lbConf['wanCache'] = $wCache;
}
return $lbConf;
}
示例6: send_log
/**
* storeData -- push data frame to Stomp
*
* @param String $type
* @author Piotr Molski (MoLi)
* @access private
*
*/
private function send_log()
{
wfProfileIn(__METHOD__);
try {
$data = json_encode(array('cityId' => $this->mCityId, 'pageId' => $this->mPageId, 'revId' => $this->mRevId, 'logId' => $this->mLogId, 'serverName' => $this->mServerName, 'archive' => $this->mArchive, 'hostname' => wfHostname(), 'beaconId' => wfGetBeaconId()));
WScribeClient::singleton($this->mKey)->send($data);
} catch (TException $e) {
Wikia::log(__METHOD__, 'scribeClient exception', $e->getMessage());
}
wfProfileOut(__METHOD__);
}
示例7: getInstance
/**
* Returns TransactionTrace singleton instance
*
* @return TransactionTrace
*/
public static function getInstance()
{
static $instance;
if ($instance === null) {
global $wgWikiaEnvironment;
$instance = new TransactionTrace(array(new TransactionTraceNewrelic(), new TransactionTraceScribe()));
$instance->set(self::PARAM_ENVIRONMENT, $wgWikiaEnvironment);
$instance->set(self::PARAM_HOSTNAME, wfHostname());
$instance->set(self::PARAM_PHP_VERSION, explode('-', phpversion())[0]);
// report "5.4.17-1~precise+1" as "5.4.17"
}
return $instance;
}
示例8: logData
/**
* Log the whole profiling data into the database.
*/
public function logData()
{
global $wgProfilePerHost;
# Do not log anything if database is readonly (bug 5375)
if (wfReadOnly()) {
return;
}
if ($wgProfilePerHost) {
$pfhost = wfHostname();
} else {
$pfhost = '';
}
try {
$this->collateData();
$dbw = wfGetDB(DB_MASTER);
$useTrx = $dbw->getType() === 'sqlite';
// much faster
if ($useTrx) {
$dbw->begin();
}
foreach ($this->mCollated as $name => $data) {
$eventCount = $data['count'];
$timeSum = (double) ($data['real'] * 1000);
$memorySum = (double) $data['memory'];
$name = substr($name, 0, 255);
// Kludge
$timeSum = $timeSum >= 0 ? $timeSum : 0;
$memorySum = $memorySum >= 0 ? $memorySum : 0;
$dbw->update('profiling', array("pf_count=pf_count+{$eventCount}", "pf_time=pf_time+{$timeSum}", "pf_memory=pf_memory+{$memorySum}"), array('pf_name' => $name, 'pf_server' => $pfhost), __METHOD__);
$rc = $dbw->affectedRows();
if ($rc == 0) {
$dbw->insert('profiling', array('pf_name' => $name, 'pf_count' => $eventCount, 'pf_time' => $timeSum, 'pf_memory' => $memorySum, 'pf_server' => $pfhost), __METHOD__, array('IGNORE'));
}
// When we upgrade to mysql 4.1, the insert+update
// can be merged into just a insert with this construct added:
// "ON DUPLICATE KEY UPDATE ".
// "pf_count=pf_count + VALUES(pf_count), ".
// "pf_time=pf_time + VALUES(pf_time)";
}
if ($useTrx) {
$dbw->commit();
}
} catch (DBError $e) {
}
}
示例9: wfCheckPAD
function wfCheckPAD($url, $pad)
{
global $wgServer, $wgTitle, $wgCookieDomain;
if ($wgServer == "http://testers.wikihow.com") {
return true;
}
if (($wgServer == "http://www.wikihow.com" || strpos(wfHostname(), "wikihow.com") !== false) && strpos($pad, "whstatic") === false) {
$alerts = new MailAddress("alerts@wikihow.com");
// format of date to correspond to varnish file 04/Dec/2010:07:19:06 -0800
$now = date("d/M/Y:h:i:s O");
$subject = "Not using PAD for thumbnail on " . wfHostname() . " - " . $now;
$body = "article {$wgTitle->getFullURL()}\n\n\nUrl: {$url} \n\n \npad {$pad} \n\n\nserver variables " . print_r($_SERVER, true) . "\n\n allheaders: " . print_r(getallheaders(), true) . "\n\n wgserver {$wgServer}\n\ncookie domain {$wgCookieDomain}\n\n Title " . print_r($wgTitle, true) . "\n\nbacktrace: " . strip_tags(wfBacktrace());
UserMailer::send($alerts, $alerts, $subject, $body, $alerts);
error_log($body);
wfDebug($body);
}
return true;
}
示例10: wfStreamFile
/** */
function wfStreamFile($fname, $headers = array())
{
$stat = @stat($fname);
if (!$stat) {
header('HTTP/1.0 404 Not Found');
header('Cache-Control: no-cache');
header('Content-Type: text/html; charset=utf-8');
$encFile = htmlspecialchars($fname);
$encScript = htmlspecialchars($_SERVER['SCRIPT_NAME']);
echo "<html><body>\n<h1>File not found</h1>\n<p>Although this PHP script ({$encScript}) exists, the file requested for output \n({$encFile}) does not.</p>\n</body></html>\n";
return;
}
header('Last-Modified: ' . gmdate('D, d M Y H:i:s', $stat['mtime']) . ' GMT');
// Cancel output buffering and gzipping if set
wfResetOutputBuffers();
$type = wfGetType($fname);
if ($type and $type != "unknown/unknown") {
header("Content-type: {$type}");
} else {
header('Content-type: application/x-wiki');
}
global $wgContLanguageCode;
header("Content-Disposition: inline;filename*=utf-8'{$wgContLanguageCode}'" . urlencode(basename($fname)));
foreach ($headers as $header) {
header($header);
}
if (!empty($_SERVER['HTTP_IF_MODIFIED_SINCE'])) {
$modsince = preg_replace('/;.*$/', '', $_SERVER['HTTP_IF_MODIFIED_SINCE']);
$sinceTime = strtotime($modsince);
if ($stat['mtime'] <= $sinceTime) {
header("HTTP/1.0 304 Not Modified");
return;
}
}
$h = "";
foreach ($stat as $k => $v) {
$h .= "{$k}={$v},";
}
header('Content-Length: ' . $stat['size']);
header('X-stat-results: ' . $h);
header('X-Serving-host: ' . wfHostname());
header('Content-Length-true: ' . $stat['size']);
readfile($fname);
}
示例11: parse
//.........这里部分代码省略.........
* c) It's a conversion table
* d) it is an interface message (which is in the user language)
*/
if (!($options->getDisableContentConversion() || isset($this->mDoubleUnderscores['nocontentconvert']))) {
if (!$this->mOptions->getInterfaceMessage()) {
# The position of the convert() call should not be changed. it
# assumes that the links are all replaced and the only thing left
# is the <nowiki> mark.
$text = $this->getConverterLanguage()->convert($text);
}
}
/**
* A converted title will be provided in the output object if title and
* content conversion are enabled, the article text does not contain
* a conversion-suppressing double-underscore tag, and no
* {{DISPLAYTITLE:...}} is present. DISPLAYTITLE takes precedence over
* automatic link conversion.
*/
if (!($options->getDisableTitleConversion() || isset($this->mDoubleUnderscores['nocontentconvert']) || isset($this->mDoubleUnderscores['notitleconvert']) || $this->mOutput->getDisplayTitle() !== false)) {
$convruletitle = $this->getConverterLanguage()->getConvRuleTitle();
if ($convruletitle) {
$this->mOutput->setTitleText($convruletitle);
} else {
$titleText = $this->getConverterLanguage()->convertTitle($title);
$this->mOutput->setTitleText($titleText);
}
}
$text = $this->mStripState->unstripNoWiki($text);
wfRunHooks('ParserBeforeTidy', array(&$this, &$text));
$text = $this->replaceTransparentTags($text);
$text = $this->mStripState->unstripGeneral($text);
$text = Sanitizer::normalizeCharReferences($text);
if ($wgUseTidy && $this->mOptions->getTidy() || $wgAlwaysUseTidy) {
$text = MWTidy::tidy($text);
} else {
# attempt to sanitize at least some nesting problems
# (bug #2702 and quite a few others)
$tidyregs = array('/(<([bi])>)(<([bi])>)?([^<]*)(<\\/?a[^<]*>)([^<]*)(<\\/\\4>)?(<\\/\\2>)/' => '\\1\\3\\5\\8\\9\\6\\1\\3\\7\\8\\9', '/(<a[^>]+>)([^<]*)(<a[^>]+>[^<]*)<\\/a>(.*)<\\/a>/' => '\\1\\2</a>\\3</a>\\1\\4</a>', '/(<([aib]) [^>]+>)([^<]*)(<div([^>]*)>)(.*)(<\\/div>)([^<]*)(<\\/\\2>)/' => '\\1\\3<div\\5>\\6</div>\\8\\9', '/<([bi])><\\/\\1>/' => '');
$text = preg_replace(array_keys($tidyregs), array_values($tidyregs), $text);
}
if ($this->mExpensiveFunctionCount > $this->mOptions->getExpensiveParserFunctionLimit()) {
$this->limitationWarn('expensive-parserfunction', $this->mExpensiveFunctionCount, $this->mOptions->getExpensiveParserFunctionLimit());
}
wfRunHooks('ParserAfterTidy', array(&$this, &$text));
# Information on include size limits, for the benefit of users who try to skirt them
if ($this->mOptions->getEnableLimitReport()) {
$max = $this->mOptions->getMaxIncludeSize();
$cpuTime = $this->mOutput->getTimeSinceStart('cpu');
if ($cpuTime !== null) {
$this->mOutput->setLimitReportData('limitreport-cputime', sprintf("%.3f", $cpuTime));
}
$wallTime = $this->mOutput->getTimeSinceStart('wall');
$this->mOutput->setLimitReportData('limitreport-walltime', sprintf("%.3f", $wallTime));
$this->mOutput->setLimitReportData('limitreport-ppvisitednodes', array($this->mPPNodeCount, $this->mOptions->getMaxPPNodeCount()));
$this->mOutput->setLimitReportData('limitreport-ppgeneratednodes', array($this->mGeneratedPPNodeCount, $this->mOptions->getMaxGeneratedPPNodeCount()));
$this->mOutput->setLimitReportData('limitreport-postexpandincludesize', array($this->mIncludeSizes['post-expand'], $max));
$this->mOutput->setLimitReportData('limitreport-templateargumentsize', array($this->mIncludeSizes['arg'], $max));
$this->mOutput->setLimitReportData('limitreport-expansiondepth', array($this->mHighestExpansionDepth, $this->mOptions->getMaxPPExpandDepth()));
$this->mOutput->setLimitReportData('limitreport-expensivefunctioncount', array($this->mExpensiveFunctionCount, $this->mOptions->getExpensiveParserFunctionLimit()));
wfRunHooks('ParserLimitReportPrepare', array($this, $this->mOutput));
$limitReport = "NewPP limit report\n";
if ($wgShowHostnames) {
$limitReport .= 'Parsed by ' . wfHostname() . "\n";
}
foreach ($this->mOutput->getLimitReportData() as $key => $value) {
if (wfRunHooks('ParserLimitReportFormat', array($key, &$value, &$limitReport, false, false))) {
$keyMsg = wfMessage($key)->inLanguage('en')->useDatabase(false);
$valueMsg = wfMessage(array("{$key}-value-text", "{$key}-value"))->inLanguage('en')->useDatabase(false);
if (!$valueMsg->exists()) {
$valueMsg = new RawMessage('$1');
}
if (!$keyMsg->isDisabled() && !$valueMsg->isDisabled()) {
$valueMsg->params($value);
$limitReport .= "{$keyMsg->text()}: {$valueMsg->text()}\n";
}
}
}
// Since we're not really outputting HTML, decode the entities and
// then re-encode the things that need hiding inside HTML comments.
$limitReport = htmlspecialchars_decode($limitReport);
wfRunHooks('ParserLimitReport', array($this, &$limitReport));
// Sanitize for comment. Note '‐' in the replacement is U+2010,
// which looks much like the problematic '-'.
$limitReport = str_replace(array('-', '&'), array('‐', '&'), $limitReport);
$text .= "\n<!-- \n{$limitReport}-->\n";
if ($this->mGeneratedPPNodeCount > $this->mOptions->getMaxGeneratedPPNodeCount() / 10) {
wfDebugLog('generated-pp-node-count', $this->mGeneratedPPNodeCount . ' ' . $this->mTitle->getPrefixedDBkey());
}
}
$this->mOutput->setText($text);
$this->mRevisionId = $oldRevisionId;
$this->mRevisionObject = $oldRevisionObject;
$this->mRevisionTimestamp = $oldRevisionTimestamp;
$this->mRevisionUser = $oldRevisionUser;
$this->mRevisionSize = $oldRevisionSize;
$this->mInputSize = false;
wfProfileOut($fname);
wfProfileOut(__METHOD__);
return $this->mOutput;
}
示例12: openForeignConnection
/**
* Open a connection to a foreign DB, or return one if it is already open.
*
* Increments a reference count on the returned connection which locks the
* connection to the requested wiki. This reference count can be
* decremented by calling reuseConnection().
*
* If a connection is open to the appropriate server already, but with the wrong
* database, it will be switched to the right database and returned, as long as
* it has been freed first with reuseConnection().
*
* On error, returns false, and the connection which caused the
* error will be available via $this->mErrorConnection.
*
* @param int $i Server index
* @param string $wiki Wiki ID to open
* @return DatabaseBase
*/
private function openForeignConnection($i, $wiki)
{
list($dbName, $prefix) = wfSplitWikiID($wiki);
if (isset($this->mConns['foreignUsed'][$i][$wiki])) {
// Reuse an already-used connection
$conn = $this->mConns['foreignUsed'][$i][$wiki];
wfDebug(__METHOD__ . ": reusing connection {$i}/{$wiki}\n");
} elseif (isset($this->mConns['foreignFree'][$i][$wiki])) {
// Reuse a free connection for the same wiki
$conn = $this->mConns['foreignFree'][$i][$wiki];
unset($this->mConns['foreignFree'][$i][$wiki]);
$this->mConns['foreignUsed'][$i][$wiki] = $conn;
wfDebug(__METHOD__ . ": reusing free connection {$i}/{$wiki}\n");
} elseif (!empty($this->mConns['foreignFree'][$i])) {
// Reuse a connection from another wiki
$conn = reset($this->mConns['foreignFree'][$i]);
$oldWiki = key($this->mConns['foreignFree'][$i]);
// The empty string as a DB name means "don't care".
// DatabaseMysqlBase::open() already handle this on connection.
if ($dbName !== '' && !$conn->selectDB($dbName)) {
$this->mLastError = "Error selecting database {$dbName} on server " . $conn->getServer() . " from client host " . wfHostname() . "\n";
$this->mErrorConnection = $conn;
$conn = false;
} else {
$conn->tablePrefix($prefix);
unset($this->mConns['foreignFree'][$i][$oldWiki]);
$this->mConns['foreignUsed'][$i][$wiki] = $conn;
wfDebug(__METHOD__ . ": reusing free connection from {$oldWiki} for {$wiki}\n");
}
} else {
// Open a new connection
$server = $this->mServers[$i];
$server['serverIndex'] = $i;
$server['foreignPoolRefCount'] = 0;
$server['foreign'] = true;
$conn = $this->reallyOpenConnection($server, $dbName);
if (!$conn->isOpen()) {
wfDebug(__METHOD__ . ": error opening connection for {$i}/{$wiki}\n");
$this->mErrorConnection = $conn;
$conn = false;
} else {
$conn->tablePrefix($prefix);
$this->mConns['foreignUsed'][$i][$wiki] = $conn;
wfDebug(__METHOD__ . ": opened new connection for {$i}/{$wiki}\n");
}
}
// Increment reference count
if ($conn) {
$refCount = $conn->getLBInfo('foreignPoolRefCount');
$conn->setLBInfo('foreignPoolRefCount', $refCount + 1);
}
return $conn;
}
示例13: parse
/**
* Convert wikitext to HTML
* Do not call this function recursively.
*
* @param string $text Text we want to parse
* @param Title $title
* @param ParserOptions $options
* @param bool $linestart
* @param bool $clearState
* @param int $revid Number to pass in {{REVISIONID}}
* @return ParserOutput A ParserOutput
*/
public function parse($text, Title $title, ParserOptions $options, $linestart = true, $clearState = true, $revid = null)
{
/**
* First pass--just handle <nowiki> sections, pass the rest off
* to internalParse() which does all the real work.
*/
global $wgShowHostnames;
if ($clearState) {
// We use U+007F DELETE to construct strip markers, so we have to make
// sure that this character does not occur in the input text.
$text = strtr($text, "", "?");
$magicScopeVariable = $this->lock();
}
$this->startParse($title, $options, self::OT_HTML, $clearState);
$this->currentRevisionCache = null;
$this->mInputSize = strlen($text);
if ($this->mOptions->getEnableLimitReport()) {
$this->mOutput->resetParseStartTime();
}
$oldRevisionId = $this->mRevisionId;
$oldRevisionObject = $this->mRevisionObject;
$oldRevisionTimestamp = $this->mRevisionTimestamp;
$oldRevisionUser = $this->mRevisionUser;
$oldRevisionSize = $this->mRevisionSize;
if ($revid !== null) {
$this->mRevisionId = $revid;
$this->mRevisionObject = null;
$this->mRevisionTimestamp = null;
$this->mRevisionUser = null;
$this->mRevisionSize = null;
}
Hooks::run('ParserBeforeStrip', array(&$this, &$text, &$this->mStripState));
# No more strip!
Hooks::run('ParserAfterStrip', array(&$this, &$text, &$this->mStripState));
$text = $this->internalParse($text);
Hooks::run('ParserAfterParse', array(&$this, &$text, &$this->mStripState));
$text = $this->internalParseHalfParsed($text, true, $linestart);
/**
* A converted title will be provided in the output object if title and
* content conversion are enabled, the article text does not contain
* a conversion-suppressing double-underscore tag, and no
* {{DISPLAYTITLE:...}} is present. DISPLAYTITLE takes precedence over
* automatic link conversion.
*/
if (!($options->getDisableTitleConversion() || isset($this->mDoubleUnderscores['nocontentconvert']) || isset($this->mDoubleUnderscores['notitleconvert']) || $this->mOutput->getDisplayTitle() !== false)) {
$convruletitle = $this->getConverterLanguage()->getConvRuleTitle();
if ($convruletitle) {
$this->mOutput->setTitleText($convruletitle);
} else {
$titleText = $this->getConverterLanguage()->convertTitle($title);
$this->mOutput->setTitleText($titleText);
}
}
if ($this->mExpensiveFunctionCount > $this->mOptions->getExpensiveParserFunctionLimit()) {
$this->limitationWarn('expensive-parserfunction', $this->mExpensiveFunctionCount, $this->mOptions->getExpensiveParserFunctionLimit());
}
# Information on include size limits, for the benefit of users who try to skirt them
if ($this->mOptions->getEnableLimitReport()) {
$max = $this->mOptions->getMaxIncludeSize();
$cpuTime = $this->mOutput->getTimeSinceStart('cpu');
if ($cpuTime !== null) {
$this->mOutput->setLimitReportData('limitreport-cputime', sprintf("%.3f", $cpuTime));
}
$wallTime = $this->mOutput->getTimeSinceStart('wall');
$this->mOutput->setLimitReportData('limitreport-walltime', sprintf("%.3f", $wallTime));
$this->mOutput->setLimitReportData('limitreport-ppvisitednodes', array($this->mPPNodeCount, $this->mOptions->getMaxPPNodeCount()));
$this->mOutput->setLimitReportData('limitreport-ppgeneratednodes', array($this->mGeneratedPPNodeCount, $this->mOptions->getMaxGeneratedPPNodeCount()));
$this->mOutput->setLimitReportData('limitreport-postexpandincludesize', array($this->mIncludeSizes['post-expand'], $max));
$this->mOutput->setLimitReportData('limitreport-templateargumentsize', array($this->mIncludeSizes['arg'], $max));
$this->mOutput->setLimitReportData('limitreport-expansiondepth', array($this->mHighestExpansionDepth, $this->mOptions->getMaxPPExpandDepth()));
$this->mOutput->setLimitReportData('limitreport-expensivefunctioncount', array($this->mExpensiveFunctionCount, $this->mOptions->getExpensiveParserFunctionLimit()));
Hooks::run('ParserLimitReportPrepare', array($this, $this->mOutput));
$limitReport = "NewPP limit report\n";
if ($wgShowHostnames) {
$limitReport .= 'Parsed by ' . wfHostname() . "\n";
}
$limitReport .= 'Cached time: ' . $this->mOutput->getCacheTime() . "\n";
$limitReport .= 'Cache expiry: ' . $this->mOutput->getCacheExpiry() . "\n";
$limitReport .= 'Dynamic content: ' . ($this->mOutput->hasDynamicContent() ? 'true' : 'false') . "\n";
foreach ($this->mOutput->getLimitReportData() as $key => $value) {
if (Hooks::run('ParserLimitReportFormat', array($key, &$value, &$limitReport, false, false))) {
$keyMsg = wfMessage($key)->inLanguage('en')->useDatabase(false);
$valueMsg = wfMessage(array("{$key}-value-text", "{$key}-value"))->inLanguage('en')->useDatabase(false);
if (!$valueMsg->exists()) {
$valueMsg = new RawMessage('$1');
}
if (!$keyMsg->isDisabled() && !$valueMsg->isDisabled()) {
$valueMsg->params($value);
//.........这里部分代码省略.........
示例14: doTransform
function doTransform($image, $dstPath, $dstUrl, $params, $flags = 0)
{
global $wgDjvuRenderer, $wgDjvuPostProcessor;
// Fetch XML and check it, to give a more informative error message than the one which
// normaliseParams will inevitably give.
$xml = $image->getMetadata();
if (!$xml) {
return new MediaTransformError('thumbnail_error', @$params['width'], @$params['height'], wfMsg('djvu_no_xml'));
}
if (!$this->normaliseParams($image, $params)) {
return new TransformParameterError($params);
}
$width = $params['width'];
$height = $params['height'];
$srcPath = $image->getPath();
$page = $params['page'];
if ($page > $this->pageCount($image)) {
return new MediaTransformError('thumbnail_error', $width, $height, wfMsg('djvu_page_error'));
}
if ($flags & self::TRANSFORM_LATER) {
return new ThumbnailImage($image, $dstUrl, $width, $height, $dstPath, $page);
}
if (!wfMkdirParents(dirname($dstPath))) {
return new MediaTransformError('thumbnail_error', $width, $height, wfMsg('thumbnail_dest_directory'));
}
# Use a subshell (brackets) to aggregate stderr from both pipeline commands
# before redirecting it to the overall stdout. This works in both Linux and Windows XP.
$cmd = '(' . wfEscapeShellArg($wgDjvuRenderer) . " -format=ppm -page={$page} -size={$width}x{$height} " . wfEscapeShellArg($srcPath);
if ($wgDjvuPostProcessor) {
$cmd .= " | {$wgDjvuPostProcessor}";
}
$cmd .= ' > ' . wfEscapeShellArg($dstPath) . ') 2>&1';
wfProfileIn('ddjvu');
wfDebug(__METHOD__ . ": {$cmd}\n");
$err = wfShellExec($cmd, $retval);
wfProfileOut('ddjvu');
$removed = $this->removeBadFile($dstPath, $retval);
if ($retval != 0 || $removed) {
wfDebugLog('thumbnail', sprintf('thumbnail failed on %s: error %d "%s" from "%s"', wfHostname(), $retval, trim($err), $cmd));
return new MediaTransformError('thumbnail_error', $width, $height, $err);
} else {
return new ThumbnailImage($image, $dstUrl, $width, $height, $dstPath, $page);
}
}
示例15: wfReportTime
/**
* Returns a script tag that stores the amount of time it took MediaWiki to
* handle the request in milliseconds as 'wgBackendResponseTime'.
*
* If $wgShowHostnames is true, the script will also set 'wgHostname' to the
* hostname of the server handling the request.
*
* @return string
*/
function wfReportTime()
{
global $wgRequestTime, $wgShowHostnames;
$responseTime = round((microtime(true) - $wgRequestTime) * 1000);
$reportVars = array('wgBackendResponseTime' => $responseTime);
if ($wgShowHostnames) {
$reportVars['wgHostname'] = wfHostname();
}
return Skin::makeVariablesScript($reportVars);
}