コード例 #1
0
 function setUp()
 {
     global $wgParser, $wgParserConf, $IP, $messageMemc, $wgMemc, $wgDeferredUpdateList, $wgUser, $wgLang, $wgOut, $wgRequest, $wgStyleDirectory, $wgEnableParserCache, $wgNamespaceAliases, $wgNamespaceProtection, $wgLocalFileRepo, $parserMemc, $wgThumbnailScriptPath, $wgScriptPath, $wgArticlePath, $wgStyleSheetPath, $wgScript, $wgStylePath;
     $wgScript = '/index.php';
     $wgScriptPath = '/';
     $wgArticlePath = '/wiki/$1';
     $wgStyleSheetPath = '/skins';
     $wgStylePath = '/skins';
     $wgThumbnailScriptPath = false;
     $wgLocalFileRepo = array('class' => 'LocalRepo', 'name' => 'local', 'directory' => wfTempDir() . '/test-repo', 'url' => 'http://example.com/images', 'deletedDir' => wfTempDir() . '/test-repo/delete', 'hashLevels' => 2, 'transformVia404' => false);
     $wgNamespaceProtection[NS_MEDIAWIKI] = 'editinterface';
     $wgNamespaceAliases['Image'] = NS_FILE;
     $wgNamespaceAliases['Image_talk'] = NS_FILE_TALK;
     $wgEnableParserCache = false;
     $wgDeferredUpdateList = array();
     $wgMemc = wfGetMainCache();
     $messageMemc = wfGetMessageCacheStorage();
     $parserMemc = wfGetParserCacheStorage();
     // $wgContLang = new StubContLang;
     $wgUser = new User();
     $context = new RequestContext();
     $wgLang = $context->getLang();
     $wgOut = $context->getOutput();
     $wgParser = new StubObject('wgParser', $wgParserConf['class'], array($wgParserConf));
     $wgRequest = new WebRequest();
     if ($wgStyleDirectory === false) {
         $wgStyleDirectory = "{$IP}/skins";
     }
 }
コード例 #2
0
 /**
  * Get the signleton instance of this class
  *
  * @since 1.18
  * @return MessageCache object
  */
 public static function singleton()
 {
     if (is_null(self::$instance)) {
         global $wgUseDatabaseMessages, $wgMsgCacheExpiry;
         self::$instance = new self(wfGetMessageCacheStorage(), $wgUseDatabaseMessages, $wgMsgCacheExpiry);
     }
     return self::$instance;
 }
コード例 #3
0
 function setUp()
 {
     global $wgContLang, $wgNamespaceProtection, $wgNamespaceAliases;
     global $wgHooks, $IP;
     $wgContLang = Language::factory('en');
     //Setup CLI arguments
     if ($this->getCliArg('regex=')) {
         $this->regex = $this->getCliArg('regex=');
     } else {
         # Matches anything
         $this->regex = '';
     }
     $this->keepUploads = $this->getCliArg('keep-uploads');
     $tmpGlobals = array();
     $tmpGlobals['wgScript'] = '/index.php';
     $tmpGlobals['wgScriptPath'] = '/';
     $tmpGlobals['wgArticlePath'] = '/wiki/$1';
     $tmpGlobals['wgStyleSheetPath'] = '/skins';
     $tmpGlobals['wgStylePath'] = '/skins';
     $tmpGlobals['wgThumbnailScriptPath'] = false;
     $tmpGlobals['wgLocalFileRepo'] = array('class' => 'LocalRepo', 'name' => 'local', 'url' => 'http://example.com/images', 'hashLevels' => 2, 'transformVia404' => false, 'backend' => 'local-backend');
     $tmpGlobals['wgForeignFileRepos'] = array();
     $tmpGlobals['wgEnableParserCache'] = false;
     $tmpGlobals['wgHooks'] = $wgHooks;
     $tmpGlobals['wgDeferredUpdateList'] = array();
     $tmpGlobals['wgMemc'] = wfGetMainCache();
     $tmpGlobals['messageMemc'] = wfGetMessageCacheStorage();
     $tmpGlobals['parserMemc'] = wfGetParserCacheStorage();
     // $tmpGlobals['wgContLang'] = new StubContLang;
     $tmpGlobals['wgUser'] = new User();
     $context = new RequestContext();
     $tmpGlobals['wgLang'] = $context->getLanguage();
     $tmpGlobals['wgOut'] = $context->getOutput();
     $tmpGlobals['wgParser'] = new StubObject('wgParser', $GLOBALS['wgParserConf']['class'], array($GLOBALS['wgParserConf']));
     $tmpGlobals['wgRequest'] = $context->getRequest();
     if ($GLOBALS['wgStyleDirectory'] === false) {
         $tmpGlobals['wgStyleDirectory'] = "{$IP}/skins";
     }
     foreach ($tmpGlobals as $var => $val) {
         if (array_key_exists($var, $GLOBALS)) {
             $this->savedInitialGlobals[$var] = $GLOBALS[$var];
         }
         $GLOBALS[$var] = $val;
     }
     $this->savedWeirdGlobals['mw_namespace_protection'] = $wgNamespaceProtection[NS_MEDIAWIKI];
     $this->savedWeirdGlobals['image_alias'] = $wgNamespaceAliases['Image'];
     $this->savedWeirdGlobals['image_talk_alias'] = $wgNamespaceAliases['Image_talk'];
     $wgNamespaceProtection[NS_MEDIAWIKI] = 'editinterface';
     $wgNamespaceAliases['Image'] = NS_FILE;
     $wgNamespaceAliases['Image_talk'] = NS_FILE_TALK;
 }
コード例 #4
0
 public static function suite()
 {
     $suite = new PHPUnit_Framework_TestSuite();
     self::$iter = new TestFileIterator(PARSER_TESTS);
     foreach (self::$iter as $i => $test) {
         $suite->addTest(new ParserUnitTest($i, $test['test']));
         self::$count++;
     }
     unset($tests);
     self::$parser = new PTShell();
     self::$iter->setParser(self::$parser);
     self::$parser->recorder->start();
     self::$parser->setupDatabase();
     self::$iter->rewind();
     /* } */
     /* function setUp() { */
     global $wgParser, $wgParserConf, $IP, $messageMemc, $wgMemc, $wgDeferredUpdateList, $wgUser, $wgLang, $wgOut, $wgRequest, $wgStyleDirectory, $wgEnableParserCache, $wgMessageCache, $wgUseDatabaseMessages, $wgMsgCacheExpiry, $parserMemc, $wgNamespaceAliases, $wgNamespaceProtection, $wgLocalFileRepo, $wgNamespacesWithSubpages, $wgThumbnailScriptPath, $wgScriptPath, $wgArticlePath, $wgStyleSheetPath, $wgScript, $wgStylePath;
     $wgScript = '/index.php';
     $wgScriptPath = '/';
     $wgArticlePath = '/wiki/$1';
     $wgStyleSheetPath = '/skins';
     $wgStylePath = '/skins';
     $wgThumbnailScriptPath = false;
     $wgLocalFileRepo = array('class' => 'LocalRepo', 'name' => 'local', 'directory' => '', 'url' => 'http://example.com/images', 'hashLevels' => 2, 'transformVia404' => false);
     $wgNamespaceProtection[NS_MEDIAWIKI] = 'editinterface';
     $wgNamespaceAliases['Image'] = NS_FILE;
     $wgNamespaceAliases['Image_talk'] = NS_FILE_TALK;
     $wgEnableParserCache = false;
     $wgDeferredUpdateList = array();
     $wgMemc =& wfGetMainCache();
     $messageMemc =& wfGetMessageCacheStorage();
     $parserMemc =& wfGetParserCacheStorage();
     $wgContLang = new StubContLang();
     $wgUser = new StubUser();
     $wgLang = new StubUserLang();
     $wgOut = new StubObject('wgOut', 'OutputPage');
     $wgParser = new StubObject('wgParser', $wgParserConf['class'], array($wgParserConf));
     $wgRequest = new WebRequest();
     $wgMessageCache = new StubObject('wgMessageCache', 'MessageCache', array($messageMemc, $wgUseDatabaseMessages, $wgMsgCacheExpiry, wfWikiID()));
     if ($wgStyleDirectory === false) {
         $wgStyleDirectory = "{$IP}/skins";
     }
     return $suite;
 }
コード例 #5
0
 protected function setUp()
 {
     global $wgParser, $wgParserConf, $IP, $messageMemc, $wgMemc, $wgUser, $wgLang, $wgOut, $wgRequest, $wgStyleDirectory, $wgParserCacheType, $wgNamespaceAliases, $wgNamespaceProtection, $parserMemc;
     $tmpDir = $this->getNewTempDirectory();
     $tmpGlobals = [];
     $tmpGlobals['wgScript'] = '/index.php';
     $tmpGlobals['wgScriptPath'] = '/';
     $tmpGlobals['wgArticlePath'] = '/wiki/$1';
     $tmpGlobals['wgStylePath'] = '/skins';
     $tmpGlobals['wgThumbnailScriptPath'] = false;
     $tmpGlobals['wgLocalFileRepo'] = ['class' => 'LocalRepo', 'name' => 'local', 'url' => 'http://example.com/images', 'hashLevels' => 2, 'transformVia404' => false, 'backend' => new FSFileBackend(['name' => 'local-backend', 'wikiId' => wfWikiID(), 'containerPaths' => ['local-public' => "{$tmpDir}/test-repo/public", 'local-thumb' => "{$tmpDir}/test-repo/thumb", 'local-temp' => "{$tmpDir}/test-repo/temp", 'local-deleted' => "{$tmpDir}/test-repo/delete"]])];
     foreach ($tmpGlobals as $var => $val) {
         if (array_key_exists($var, $GLOBALS)) {
             $this->savedGlobals[$var] = $GLOBALS[$var];
         }
         $GLOBALS[$var] = $val;
     }
     $wgNamespaceProtection[NS_MEDIAWIKI] = 'editinterface';
     $wgNamespaceAliases['Image'] = NS_FILE;
     $wgNamespaceAliases['Image_talk'] = NS_FILE_TALK;
     $wgParserCacheType = CACHE_NONE;
     DeferredUpdates::clearPendingUpdates();
     $wgMemc = wfGetMainCache();
     $messageMemc = wfGetMessageCacheStorage();
     $parserMemc = wfGetParserCacheStorage();
     RequestContext::resetMain();
     $context = RequestContext::getMain();
     $wgUser = new User();
     $wgLang = $context->getLanguage();
     $wgOut = $context->getOutput();
     $wgParser = new StubObject('wgParser', $wgParserConf['class'], [$wgParserConf]);
     $wgRequest = $context->getRequest();
     if ($wgStyleDirectory === false) {
         $wgStyleDirectory = "{$IP}/skins";
     }
     RepoGroup::destroySingleton();
     FileBackendGroup::destroySingleton();
 }
コード例 #6
0
ファイル: Setup.php プロジェクト: paladox/mediawiki
if ($wgCommandLineMode) {
    wfDebug("\n\nStart command line script {$self}\n");
} else {
    $debug = "\n\nStart request {$wgRequest->getMethod()} {$wgRequest->getRequestURL()}\n";
    if ($wgDebugPrintHttpHeaders) {
        $debug .= "HTTP HEADERS:\n";
        foreach ($wgRequest->getAllHeaders() as $name => $value) {
            $debug .= "{$name}: {$value}\n";
        }
    }
    wfDebug($debug);
}
Profiler::instance()->scopedProfileOut($ps_misc);
$ps_memcached = Profiler::instance()->scopedProfileIn($fname . '-memcached');
$wgMemc = wfGetMainCache();
$messageMemc = wfGetMessageCacheStorage();
$parserMemc = wfGetParserCacheStorage();
wfDebugLog('caches', 'cluster: ' . get_class($wgMemc) . ', WAN: ' . ($wgMainWANCache === CACHE_NONE ? 'CACHE_NONE' : $wgMainWANCache) . ', stash: ' . $wgMainStash . ', message: ' . get_class($messageMemc) . ', parser: ' . get_class($parserMemc) . ', session: ' . get_class(ObjectCache::getInstance($wgSessionCacheType)));
Profiler::instance()->scopedProfileOut($ps_memcached);
// Most of the config is out, some might want to run hooks here.
Hooks::run('SetupAfterCache');
$ps_globals = Profiler::instance()->scopedProfileIn($fname . '-globals');
/**
 * @var Language $wgContLang
 */
$wgContLang = Language::factory($wgLanguageCode);
$wgContLang->initContLang();
// Now that variant lists may be available...
$wgRequest->interpolateTitle();
if (!is_object($wgAuth)) {
    $wgAuth = new MediaWiki\Auth\AuthManagerAuthPlugin();