예제 #1
0
파일: Setup.php 프로젝트: paladox/mediawiki
// is complete.
define('MW_SERVICE_BOOTSTRAP_COMPLETE', 1);
// Install a header callback to prevent caching of responses with cookies (T127993)
if (!$wgCommandLineMode) {
    header_register_callback(function () {
        $headers = [];
        foreach (headers_list() as $header) {
            list($name, $value) = explode(':', $header, 2);
            $headers[strtolower(trim($name))][] = trim($value);
        }
        if (isset($headers['set-cookie'])) {
            $cacheControl = isset($headers['cache-control']) ? implode(', ', $headers['cache-control']) : '';
            if (!preg_match('/(?:^|,)\\s*(?:private|no-cache|no-store)\\s*(?:$|,)/i', $cacheControl)) {
                header('Expires: Thu, 01 Jan 1970 00:00:00 GMT');
                header('Cache-Control: private, max-age=0, s-maxage=0');
                MediaWiki\Logger\LoggerFactory::getInstance('cache-cookies')->warning('Cookies set on {url} with Cache-Control "{cache-control}"', ['url' => WebRequest::getGlobalRequestURL(), 'cookies' => $headers['set-cookie'], 'cache-control' => $cacheControl ?: '<not set>']);
            }
        }
    });
}
MWExceptionHandler::installHandler();
require_once "{$IP}/includes/compat/normal/UtfNormalUtil.php";
$ps_validation = Profiler::instance()->scopedProfileIn($fname . '-validation');
// T48998: Bail out early if $wgArticlePath is non-absolute
foreach (['wgArticlePath', 'wgVariantArticlePath'] as $varName) {
    if (${$varName} && !preg_match('/^(https?:\\/\\/|\\/)/', ${$varName})) {
        throw new FatalError("If you use a relative URL for \${$varName}, it must start " . 'with a slash (<code>/</code>).<br><br>See ' . "<a href=\"https://www.mediawiki.org/wiki/Manual:\${$varName}\">" . "https://www.mediawiki.org/wiki/Manual:\${$varName}</a>.");
    }
}
Profiler::instance()->scopedProfileOut($ps_validation);
$ps_default2 = Profiler::instance()->scopedProfileIn($fname . '-defaults2');
예제 #2
0
// five edits
// Caching
$wgObjectCaches['redis'] = array('class' => 'RedisBagOStuff', 'servers' => array('127.0.0.1:6379'), 'persistent' => true);
$wgMainCacheType = 'redis';
// Avoid user request serialization and other slowness
$wgSessionCacheType = 'redis';
$wgSessionsInObjectCache = true;
// Jobqueue
$wgJobTypeConf['default'] = array('class' => 'JobQueueRedis', 'daemonized' => true, 'redisServer' => '127.0.0.1', 'redisConfig' => array('connectTimeout' => 2, 'compression' => 'gzip'));
$wgJobQueueAggregator = array('class' => 'JobQueueAggregatorRedis', 'redisServers' => array('127.0.0.1'), 'redisConfig' => array('connectTimeout' => 2));
$wgLegacyJavaScriptGlobals = false;
$wgEnableJavaScriptTest = true;
require_once __DIR__ . '/settings.d/wikis/CommonSettings.php';
// XXX: Is this a bug in core? (ori-l, 27-Aug-2013)
$wgHooks['GetIP'][] = function (&$ip) {
    if (PHP_SAPI === 'cli') {
        $ip = '127.0.0.1';
    }
    return true;
};
// Execute all jobs via standalone jobrunner service rather than
// piggybacking them on web requests.
$wgJobRunRate = 0;
// Bug 73037: handmade gzipping sometimes makes error messages impossible to see in HHVM
$wgDisableOutputCompression = true;
// Allow 'vagrant' password.
$wgPasswordPolicy['policies']['sysop']['MinimalPasswordLength'] = 7;
$wgPasswordPolicy['policies']['bureaucrat']['MinimalPasswordLength'] = 7;
// Ensure that full LoggerFactory configuration is applied
MediaWiki\Logger\LoggerFactory::registerProvider(ObjectFactory::getObjectFromSpec($wgMWLoggerDefaultSpi));
 /**
  * @return bool
  */
 public function doWork()
 {
     global $wgUseFileCache;
     // @todo several of the methods called on $this->page are not declared in Page, but present
     //        in WikiPage and delegated by Article.
     $isCurrent = $this->revid === $this->page->getLatest();
     if ($this->content !== null) {
         $content = $this->content;
     } elseif ($isCurrent) {
         // XXX: why use RAW audience here, and PUBLIC (default) below?
         $content = $this->page->getContent(Revision::RAW);
     } else {
         $rev = Revision::newFromTitle($this->page->getTitle(), $this->revid);
         if ($rev === null) {
             $content = null;
         } else {
             // XXX: why use PUBLIC audience here (default), and RAW above?
             $content = $rev->getContent();
         }
     }
     if ($content === null) {
         return false;
     }
     // Reduce effects of race conditions for slow parses (bug 46014)
     $cacheTime = wfTimestampNow();
     $time = -microtime(true);
     $this->parserOutput = $content->getParserOutput($this->page->getTitle(), $this->revid, $this->parserOptions);
     $time += microtime(true);
     // Timing hack
     if ($time > 3) {
         // TODO: Use Parser's logger (once it has one)
         $logger = MediaWiki\Logger\LoggerFactory::getInstance('slow-parse');
         $logger->info('{time} {title}', array('time' => number_format($time, 2), 'title' => $this->page->getTitle()->getPrefixedDBkey()));
     }
     if ($this->cacheable && $this->parserOutput->isCacheable() && $isCurrent) {
         ParserCache::singleton()->save($this->parserOutput, $this->page, $this->parserOptions, $cacheTime, $this->revid);
     }
     // Make sure file cache is not used on uncacheable content.
     // Output that has magic words in it can still use the parser cache
     // (if enabled), though it will generally expire sooner.
     if (!$this->parserOutput->isCacheable()) {
         $wgUseFileCache = false;
     }
     if ($isCurrent) {
         $this->page->triggerOpportunisticLinksUpdate($this->parserOutput);
     }
     return true;
 }
    $extractors['header'][] = $extractors['post-summary'][] = new Flow\Parsoid\Extractor\CategoryExtractor();
    return new Flow\Parsoid\ReferenceExtractor($extractors);
};
$c['reference.recorder'] = function ($c) {
    return new Flow\Data\Listener\ReferenceRecorder($c['reference.extractor'], $c['reference.updater.links-tables'], $c['storage'], $c['repository.tree']);
};
$c['user_merger'] = function ($c) {
    return new Flow\Data\Utils\UserMerger($c['db.factory'], $c['storage']);
};
$c['importer'] = function ($c) {
    $importer = new Flow\Import\Importer($c['storage'], $c['factory.loader.workflow'], $c['memcache.buffered'], $c['db.factory'], $c['deferred_queue'], $c['occupation_controller']);
    $importer->addPostprocessor(new Flow\Import\Postprocessor\SpecialLogTopic($c['occupation_controller']->getTalkpageManager()));
    return $importer;
};
$c['listener.editcount'] = function ($c) {
    return new \Flow\Data\Listener\EditCountListener($c['flow_actions']);
};
$c['formatter.undoedit'] = function ($c) {
    return new Flow\Formatter\RevisionUndoViewFormatter($c['formatter.revisionview']);
};
$c['board_mover'] = function ($c) {
    return new Flow\BoardMover($c['db.factory'], $c['memcache.buffered'], $c['storage'], $c['occupation_controller']->getTalkpageManager());
};
$c['parser'] = function () {
    global $wgParser;
    return $wgParser;
};
$c['default_logger'] = function () {
    return MediaWiki\Logger\LoggerFactory::getInstance('Flow');
};
return $c;