本文整理汇总了PHP中MediaWiki\Logger\LoggerFactory类的典型用法代码示例。如果您正苦于以下问题:PHP LoggerFactory类的具体用法?PHP LoggerFactory怎么用?PHP LoggerFactory使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了LoggerFactory类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: applyDefaultParameters
/**
* @param array $params
* @param Config $mainConfig
* @return array
*/
public static function applyDefaultParameters(array $params, Config $mainConfig)
{
$logger = LoggerFactory::getInstance('Mime');
$params += ['typeFile' => $mainConfig->get('MimeTypeFile'), 'infoFile' => $mainConfig->get('MimeInfoFile'), 'xmlTypes' => $mainConfig->get('XMLMimeTypes'), 'guessCallback' => function ($mimeAnalyzer, &$head, &$tail, $file, &$mime) use($logger) {
// Also test DjVu
$deja = new DjVuImage($file);
if ($deja->isValid()) {
$logger->info(__METHOD__ . ": detected {$file} as image/vnd.djvu\n");
$mime = 'image/vnd.djvu';
return;
}
// Some strings by reference for performance - assuming well-behaved hooks
Hooks::run('MimeMagicGuessFromContent', [$mimeAnalyzer, &$head, &$tail, $file, &$mime]);
}, 'extCallback' => function ($mimeAnalyzer, $ext, &$mime) {
// Media handling extensions can improve the MIME detected
Hooks::run('MimeMagicImproveFromExtension', [$mimeAnalyzer, $ext, &$mime]);
}, 'initCallback' => function ($mimeAnalyzer) {
// Allow media handling extensions adding MIME-types and MIME-info
Hooks::run('MimeMagicInit', [$mimeAnalyzer]);
}, 'logger' => $logger];
if ($params['infoFile'] === 'includes/mime.info') {
$params['infoFile'] = __DIR__ . "/libs/mime/mime.info";
}
if ($params['typeFile'] === 'includes/mime.types') {
$params['typeFile'] = __DIR__ . "/libs/mime/mime.types";
}
$detectorCmd = $mainConfig->get('MimeDetectorCommand');
if ($detectorCmd) {
$params['detectCallback'] = function ($file) use($detectorCmd) {
return wfShellExec("{$detectorCmd} " . wfEscapeShellArg($file));
};
}
return $params;
}
开发者ID:paladox,项目名称:mediawiki,代码行数:39,代码来源:MimeMagic.php
示例2: execute
public function execute()
{
global $wgCommandLineMode;
if ($this->hasOption('procs')) {
$procs = intval($this->getOption('procs'));
if ($procs < 1 || $procs > 1000) {
$this->error("Invalid argument to --procs", true);
} elseif ($procs != 1) {
$fc = new ForkController($procs);
if ($fc->start() != 'child') {
exit(0);
}
}
}
$outputJSON = $this->getOption('result') === 'json';
// Enable DBO_TRX for atomicity; JobRunner manages transactions
// and works well in web server mode already (@TODO: this is a hack)
$wgCommandLineMode = false;
$runner = new JobRunner(LoggerFactory::getInstance('runJobs'));
if (!$outputJSON) {
$runner->setDebugHandler(array($this, 'debugInternal'));
}
$response = $runner->run(array('type' => $this->getOption('type', false), 'maxJobs' => $this->getOption('maxjobs', false), 'maxTime' => $this->getOption('maxtime', false), 'throttle' => $this->hasOption('nothrottle') ? false : true));
if ($outputJSON) {
$this->output(FormatJson::encode($response, true));
}
$wgCommandLineMode = true;
}
开发者ID:admonkey,项目名称:mediawiki,代码行数:28,代码来源:runJobs.php
示例3: __construct
/**
* @param LoggerInterface $logger
*/
public function __construct(LoggerInterface $logger = null)
{
if ($logger === null) {
$logger = LoggerFactory::getInstance('runJobs');
}
$this->setLogger($logger);
}
开发者ID:eliagbayani,项目名称:LiteratureEditor,代码行数:10,代码来源:JobRunner.php
示例4: getMonthViews
protected static function getMonthViews(Title $title)
{
global $wgMemc;
$key = wfMemcKey('pvi', 'month', md5($title->getPrefixedText()));
$data = $wgMemc->get($key);
if ($data) {
return $data;
}
$today = date('Ymd');
$lastMonth = date('Ymd', time() - 60 * 60 * 24 * 30);
$url = self::buildApiUrl($title, $lastMonth, $today);
$req = MWHttpRequest::factory($url, ['timeout' => 10], __METHOD__);
$status = $req->execute();
if (!$status->isOK()) {
LoggerFactory::getInstance('PageViewInfo')->error("Failed fetching {$url}: {$status->getWikiText()}", ['url' => $url, 'title' => $title->getPrefixedText()]);
return false;
}
$data = FormatJson::decode($req->getContent(), true);
// Add our start/end periods
$data['start'] = $lastMonth;
$data['end'] = $today;
// Cache for an hour
$wgMemc->set($key, $data, 60 * 60);
return $data;
}
开发者ID:wikimedia,项目名称:mediawiki-extensions-WikimediaPageViewInfo,代码行数:25,代码来源:PageViewInfo.hooks.php
示例5: execute
public function execute()
{
if (wfReadOnly()) {
$this->error("Unable to run jobs; the wiki is in read-only mode.", 1);
// die
}
if ($this->hasOption('procs')) {
$procs = intval($this->getOption('procs'));
if ($procs < 1 || $procs > 1000) {
$this->error("Invalid argument to --procs", true);
} elseif ($procs != 1) {
$fc = new ForkController($procs);
if ($fc->start() != 'child') {
exit(0);
}
}
}
$json = $this->getOption('result') === 'json';
$runner = new JobRunner(LoggerFactory::getInstance('runJobs'));
if (!$json) {
$runner->setDebugHandler(array($this, 'debugInternal'));
}
$response = $runner->run(array('type' => $this->getOption('type', false), 'maxJobs' => $this->getOption('maxjobs', false), 'maxTime' => $this->getOption('maxtime', false), 'throttle' => $this->hasOption('nothrottle') ? false : true));
if ($json) {
$this->output(FormatJson::encode($response, true));
}
}
开发者ID:eliagbayani,项目名称:LiteratureEditor,代码行数:27,代码来源:runJobs.php
示例6: __construct
/**
* @param array $params Possible keys:
* - redisConfig : An array of parameters to RedisConnectionPool::__construct().
* - redisServers : Array of server entries, the first being the primary and the
* others being fallback servers. Each entry is either a hostname/port
* combination or the absolute path of a UNIX socket.
* If a hostname is specified but no port, the standard port number
* 6379 will be used. Required.
*/
public function __construct(array $params)
{
parent::__construct($params);
$this->servers = isset($params['redisServers']) ? $params['redisServers'] : [$params['redisServer']];
// b/c
$params['redisConfig']['serializer'] = 'none';
$this->redisPool = RedisConnectionPool::singleton($params['redisConfig']);
$this->logger = \MediaWiki\Logger\LoggerFactory::getInstance('redis');
}
开发者ID:paladox,项目名称:mediawiki,代码行数:18,代码来源:JobQueueAggregatorRedis.php
示例7: __construct
/**
* Construct a factory based on a configuration array (typically from $wgLBFactoryConf)
* @param array $conf
*/
public function __construct(array $conf)
{
if (isset($conf['readOnlyReason']) && is_string($conf['readOnlyReason'])) {
$this->readOnlyReason = $conf['readOnlyReason'];
}
$this->chronProt = $this->newChronologyProtector();
$this->trxProfiler = Profiler::instance()->getTransactionProfiler();
$this->logger = LoggerFactory::getInstance('DBTransaction');
}
开发者ID:paladox,项目名称:2,代码行数:13,代码来源:LBFactory.php
示例8: execute
public function execute($par = '')
{
$this->getOutput()->disable();
if (wfReadOnly()) {
// HTTP 423 Locked
HttpStatus::header(423);
print 'Wiki is in read-only mode';
return;
} elseif (!$this->getRequest()->wasPosted()) {
HttpStatus::header(400);
print 'Request must be POSTed';
return;
}
$optional = array('maxjobs' => 0, 'maxtime' => 30, 'type' => false, 'async' => true);
$required = array_flip(array('title', 'tasks', 'signature', 'sigexpiry'));
$params = array_intersect_key($this->getRequest()->getValues(), $required + $optional);
$missing = array_diff_key($required, $params);
if (count($missing)) {
HttpStatus::header(400);
print 'Missing parameters: ' . implode(', ', array_keys($missing));
return;
}
$squery = $params;
unset($squery['signature']);
$correctSignature = self::getQuerySignature($squery, $this->getConfig()->get('SecretKey'));
$providedSignature = $params['signature'];
$verified = is_string($providedSignature) && hash_equals($correctSignature, $providedSignature);
if (!$verified || $params['sigexpiry'] < time()) {
HttpStatus::header(400);
print 'Invalid or stale signature provided';
return;
}
// Apply any default parameter values
$params += $optional;
if ($params['async']) {
// Client will usually disconnect before checking the response,
// but it needs to know when it is safe to disconnect. Until this
// reaches ignore_user_abort(), it is not safe as the jobs won't run.
ignore_user_abort(true);
// jobs may take a bit of time
// HTTP 202 Accepted
HttpStatus::header(202);
ob_flush();
flush();
// Once the client receives this response, it can disconnect
}
// Do all of the specified tasks...
if (in_array('jobs', explode('|', $params['tasks']))) {
$runner = new JobRunner(LoggerFactory::getInstance('runJobs'));
$response = $runner->run(array('type' => $params['type'], 'maxJobs' => $params['maxjobs'] ? $params['maxjobs'] : 1, 'maxTime' => $params['maxtime'] ? $params['maxjobs'] : 30));
if (!$params['async']) {
print FormatJson::encode($response, true);
}
}
}
开发者ID:MediaWiki-stable,项目名称:1.26.1,代码行数:55,代码来源:SpecialRunJobs.php
示例9: 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;
}
开发者ID:paladox,项目名称:mediawiki,代码行数:59,代码来源:MWLBFactory.php
示例10: execute
/**
* Logs a content-security-policy violation report from web browser.
*/
public function execute()
{
$reportOnly = $this->getParameter('reportonly');
$logname = $reportOnly ? 'csp-report-only' : 'csp';
$this->log = LoggerFactory::getInstance($logname);
$userAgent = $this->getRequest()->getHeader('user-agent');
$this->verifyPostBodyOk();
$report = $this->getReport();
$flags = $this->getFlags($report);
$warningText = $this->generateLogLine($flags, $report);
$this->logReport($flags, $warningText, ['csp-report' => $report, 'method' => __METHOD__, 'user' => $this->getUser()->getName(), 'user-agent' => $userAgent, 'source' => $this->getParameter('source')]);
$this->getResult()->addValue(null, $this->getModuleName(), 'success');
}
开发者ID:paladox,项目名称:mediawiki,代码行数:16,代码来源:ApiCSPReport.php
示例11: doLog
private function doLog()
{
$logger = LoggerFactory::getInstance('HttpError');
$content = $this->content;
if ($content instanceof Message) {
$content = $content->text();
}
$context = ['file' => $this->getFile(), 'line' => $this->getLine(), 'http_code' => $this->httpCode];
$logMsg = "{$content} ({http_code}) from {file}:{line}";
if ($this->getStatusCode() < 500) {
$logger->info($logMsg, $context);
} else {
$logger->error($logMsg, $context);
}
}
开发者ID:claudinec,项目名称:galan-wiki,代码行数:15,代码来源:HttpError.php
示例12: doJob
protected function doJob()
{
// Reload pages from pageIds to throw into the updater
$pageData = array();
foreach ($this->params['pageDBKeys'] as $pageDBKey) {
$title = Title::newFromDBKey($pageDBKey);
// Skip any titles with broken keys. We can't do anything with them.
if (!$title) {
LoggerFactory::getInstance('CirrusSearch')->warning("Skipping invalid DBKey: {pageDBKey}", array('pageDBKey' => $pageDBKey));
continue;
}
$pageData[] = WikiPage::factory($title);
}
// Now invoke the updater!
$updater = $this->createUpdater();
$count = $updater->updatePages($pageData, null, null, $this->params['updateFlags']);
return $count >= 0;
}
开发者ID:zoglun,项目名称:mediawiki-extensions-CirrusSearch,代码行数:18,代码来源:MassIndex.php
示例13: __construct
/**
* @param array $conditions An array of arrays describing throttling conditions.
* Defaults to $wgPasswordAttemptThrottle. See documentation of that variable for format.
* @param array $params Parameters (all optional):
* - type: throttle type, used as a namespace for counters,
* - cache: a BagOStuff object where throttle counters are stored.
* - warningLimit: the log level will be raised to warning when rejecting an attempt after
* no less than this many failures.
*/
public function __construct(array $conditions = null, array $params = [])
{
$invalidParams = array_diff_key($params, array_fill_keys(['type', 'cache', 'warningLimit'], true));
if ($invalidParams) {
throw new \InvalidArgumentException('unrecognized parameters: ' . implode(', ', array_keys($invalidParams)));
}
if ($conditions === null) {
$config = \ConfigFactory::getDefaultInstance()->makeConfig('main');
$conditions = $config->get('PasswordAttemptThrottle');
$params += ['type' => 'password', 'cache' => \ObjectCache::getLocalClusterInstance(), 'warningLimit' => 50];
} else {
$params += ['type' => 'custom', 'cache' => \ObjectCache::getLocalClusterInstance(), 'warningLimit' => INF];
}
$this->type = $params['type'];
$this->conditions = static::normalizeThrottleConditions($conditions);
$this->cache = $params['cache'];
$this->warningLimit = $params['warningLimit'];
$this->setLogger(LoggerFactory::getInstance('throttler'));
}
开发者ID:paladox,项目名称:mediawiki,代码行数:28,代码来源:Throttler.php
示例14: pickBest
/**
* Pick the best near match if possible.
*
* @return Title|null title if there is a near match and null otherwise
*/
public function pickBest()
{
if (!$this->titles) {
return null;
}
if (!$this->term) {
return null;
}
if (count($this->titles) === 1) {
if (isset($this->titles[0]['titleMatch'])) {
return $this->titles[0]['titleMatch'];
}
if (isset($this->titles[0]['redirectMatches'][0])) {
return $this->titles[0]['redirectMatches'][0];
}
LoggerFactory::getInstance('CirrusSearch')->info('NearMatchPicker built with busted matches. Assuming no near match');
return null;
}
$transformers = array(function ($term) {
return $term;
}, array($this->language, 'lc'), array($this->language, 'ucwords'));
foreach ($transformers as $transformer) {
$transformedTerm = call_user_func($transformer, $this->term);
$found = null;
foreach ($this->titles as $title) {
$match = $this->checkAllMatches($transformer, $transformedTerm, $title);
if ($match) {
if (!$found) {
$found = $match;
} else {
// Found more than one result so we try another transformer
$found = null;
break;
}
}
}
if ($found) {
return $found;
}
}
// Didn't find anything
return null;
}
开发者ID:jamesmontalvo3,项目名称:mediawiki-extensions-CirrusSearch,代码行数:48,代码来源:NearMatchPicker.php
示例15: execute
public function execute()
{
global $wgCommandLineMode;
if ($this->hasOption('procs')) {
$procs = intval($this->getOption('procs'));
if ($procs < 1 || $procs > 1000) {
$this->error("Invalid argument to --procs", true);
} elseif ($procs != 1) {
$fc = new ForkController($procs);
if ($fc->start() != 'child') {
exit(0);
}
}
}
$outputJSON = $this->getOption('result') === 'json';
$wait = $this->hasOption('wait');
// Enable DBO_TRX for atomicity; JobRunner manages transactions
// and works well in web server mode already (@TODO: this is a hack)
$wgCommandLineMode = false;
$runner = new JobRunner(LoggerFactory::getInstance('runJobs'));
if (!$outputJSON) {
$runner->setDebugHandler([$this, 'debugInternal']);
}
$type = $this->getOption('type', false);
$maxJobs = $this->getOption('maxjobs', false);
$maxTime = $this->getOption('maxtime', false);
$throttle = !$this->hasOption('nothrottle');
while (true) {
$response = $runner->run(['type' => $type, 'maxJobs' => $maxJobs, 'maxTime' => $maxTime, 'throttle' => $throttle]);
if ($outputJSON) {
$this->output(FormatJson::encode($response, true));
}
if (!$wait || $response['reached'] === 'time-limit' || $response['reached'] === 'job-limit' || $response['reached'] === 'memory-limit') {
break;
}
if ($maxJobs !== false) {
$maxJobs -= count($response['jobs']);
}
sleep(1);
}
$wgCommandLineMode = true;
}
开发者ID:claudinec,项目名称:galan-wiki,代码行数:42,代码来源:runJobs.php
示例16: formatWikitext
/**
* Get text to index from a ParserOutput assuming the content was wikitext.
*
* @param ParserOutput $parserOutput The parsed wikitext's parser output
* @return array who's first entry is text and second is opening text, and third is an
* array of auxiliary text
*/
private function formatWikitext(ParserOutput $parserOutput)
{
global $wgCirrusSearchBoostOpening;
$parserOutput->setEditSectionTokens(false);
$parserOutput->setTOCEnabled(false);
$text = $parserOutput->getText();
$opening = null;
switch ($wgCirrusSearchBoostOpening) {
case 'first_heading':
$opening = $this->extractHeadingBeforeFirstHeading($text);
case 'none':
break;
default:
LoggerFactory::getInstance('CirrusSearch')->warning("Invalid value for \$wgCirrusSearchBoostOpening: {wgCirrusSearchBoostOpening}", array('wgCirrusSearchBoostOpening' => $wgCirrusSearchBoostOpening));
}
// Add extra spacing around break tags so text crammed together like<br>this doesn't make one word.
$text = str_replace('<br', "\n<br", $text);
$formatter = new HtmlFormatter($text);
// Strip elements from the page that we never want in the search text.
$formatter->remove($this->excludedElementSelectors);
$filterResult = $formatter->filterContent();
if ($filterResult === null) {
// We're running against Mediawiki < 1.24wm10 which won't support auxiliary text
// because it can't extract it using the HtmlFormatter. We'll just set text to
// all the text.
$allText = trim(Sanitizer::stripAllTags($formatter->getText()));
$auxiliary = array();
} else {
// Strip elements from the page that are auxiliary text. These will still be
// searched but matches will be ranked lower and non-auxiliary matches will be
// prefered in highlighting.
$formatter->remove($this->auxiliaryElementSelectors);
$auxiliaryElements = $formatter->filterContent();
$allText = trim(Sanitizer::stripAllTags($formatter->getText()));
$auxiliary = array();
foreach ($auxiliaryElements as $auxiliaryElement) {
$auxiliary[] = trim(Sanitizer::stripAllTags($formatter->getText($auxiliaryElement)));
}
}
return array($allText, $opening, $auxiliary);
}
开发者ID:zoglun,项目名称:mediawiki-extensions-CirrusSearch,代码行数:48,代码来源:PageTextBuilder.php
示例17: cacheGetTree
/**
* Attempt to load a precomputed document tree for some given wikitext
* from the cache.
*
* @param string $text
* @param int $flags
* @return PPNode_Hash_Tree|bool
*/
protected function cacheGetTree($text, $flags)
{
$config = RequestContext::getMain()->getConfig();
$length = strlen($text);
$threshold = $config->get('PreprocessorCacheThreshold');
if ($threshold === false || $length < $threshold || $length > 1000000.0) {
return false;
}
$cache = ObjectCache::getInstance($config->get('MainCacheType'));
$key = wfMemcKey(defined('static::CACHE_PREFIX') ? static::CACHE_PREFIX : get_called_class(), md5($text), $flags);
$value = $cache->get($key);
if (!$value) {
return false;
}
$version = intval(substr($value, 0, 8));
if ($version !== static::CACHE_VERSION) {
return false;
}
LoggerFactory::getInstance('Preprocessor')->info("Loaded preprocessor output from cache (key: {$key})");
return substr($value, 8);
}
开发者ID:xfstudio,项目名称:mediawiki,代码行数:29,代码来源:Preprocessor.php
示例18: request
/**
* Perform an HTTP request
*
* @param string $method HTTP method. Usually GET/POST
* @param string $url Full URL to act on. If protocol-relative, will be expanded to an http:// URL
* @param array $options Options to pass to MWHttpRequest object.
* Possible keys for the array:
* - timeout Timeout length in seconds
* - connectTimeout Timeout for connection, in seconds (curl only)
* - postData An array of key-value pairs or a url-encoded form data
* - proxy The proxy to use.
* Otherwise it will use $wgHTTPProxy (if set)
* Otherwise it will use the environment variable "http_proxy" (if set)
* - noProxy Don't use any proxy at all. Takes precedence over proxy value(s).
* - sslVerifyHost Verify hostname against certificate
* - sslVerifyCert Verify SSL certificate
* - caInfo Provide CA information
* - maxRedirects Maximum number of redirects to follow (defaults to 5)
* - followRedirects Whether to follow redirects (defaults to false).
* Note: this should only be used when the target URL is trusted,
* to avoid attacks on intranet services accessible by HTTP.
* - userAgent A user agent, if you want to override the default
* MediaWiki/$wgVersion
* @param string $caller The method making this request, for profiling
* @return string|bool (bool)false on failure or a string on success
*/
public static function request($method, $url, $options = array(), $caller = __METHOD__)
{
wfDebug("HTTP: {$method}: {$url}\n");
$options['method'] = strtoupper($method);
if (!isset($options['timeout'])) {
$options['timeout'] = 'default';
}
if (!isset($options['connectTimeout'])) {
$options['connectTimeout'] = 'default';
}
$req = MWHttpRequest::factory($url, $options, $caller);
$status = $req->execute();
if ($status->isOK()) {
return $req->getContent();
} else {
$errors = $status->getErrorsByType('error');
$logger = LoggerFactory::getInstance('http');
$logger->warning($status->getWikiText(), array('caller' => $caller));
return false;
}
}
开发者ID:ErdemA,项目名称:mediawiki,代码行数:47,代码来源:HttpFunctions.php
示例19: onBeforePageDisplay
public static function onBeforePageDisplay(OutputPage &$out, Skin &$skin)
{
// Enable only if the user has turned it on in Beta Preferences, or BetaFeatures is not installed.
// Will only be loaded if PageImages & TextExtracts extensions are installed.
$registry = ExtensionRegistry::getInstance();
if (!$registry->isLoaded('TextExtracts') || !class_exists('ApiQueryPageImages')) {
$logger = LoggerFactory::getInstance('popups');
$logger->error('Popups requires the PageImages and TextExtracts extensions.');
return true;
}
if (self::getConfig()->get('PopupsBetaFeature') === true) {
if (!class_exists('BetaFeatures')) {
$logger = LoggerFactory::getInstance('popups');
$logger->error('PopupsMode cannot be used as a beta feature unless ' . 'the BetaFeatures extension is present.');
return true;
}
if (!BetaFeatures::isFeatureEnabled($skin->getUser(), 'popups')) {
return true;
}
}
$out->addModules(array('ext.popups', 'schema.Popups'));
return true;
}
开发者ID:webrooms,项目名称:mediawiki-extensions-Popups,代码行数:23,代码来源:Popups.hooks.php
示例20: execute
public function execute()
{
if ($this->hasOption('procs')) {
$procs = intval($this->getOption('procs'));
if ($procs < 1 || $procs > 1000) {
$this->error("Invalid argument to --procs", true);
} elseif ($procs != 1) {
$fc = new ForkController($procs);
if ($fc->start() != 'child') {
exit(0);
}
}
}
$outputJSON = $this->getOption('result') === 'json';
$wait = $this->hasOption('wait');
$runner = new JobRunner(LoggerFactory::getInstance('runJobs'));
if (!$outputJSON) {
$runner->setDebugHandler([$this, 'debugInternal']);
}
$type = $this->getOption('type', false);
$maxJobs = $this->getOption('maxjobs', false);
$maxTime = $this->getOption('maxtime', false);
$throttle = !$this->hasOption('nothrottle');
while (true) {
$response = $runner->run(['type' => $type, 'maxJobs' => $maxJobs, 'maxTime' => $maxTime, 'throttle' => $throttle]);
if ($outputJSON) {
$this->output(FormatJson::encode($response, true));
}
if (!$wait || $response['reached'] === 'time-limit' || $response['reached'] === 'job-limit' || $response['reached'] === 'memory-limit') {
break;
}
if ($maxJobs !== false) {
$maxJobs -= count($response['jobs']);
}
sleep(1);
}
}
开发者ID:paladox,项目名称:mediawiki,代码行数:37,代码来源:runJobs.php
注:本文中的MediaWiki\Logger\LoggerFactory类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论