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(); }
protected function setUp() { parent::setUp(); $this->called['setUp'] = true; $this->phpErrorLevel = intval(ini_get('error_reporting')); // Cleaning up temporary files foreach ($this->tmpFiles as $fileName) { if (is_file($fileName) || is_link($fileName)) { unlink($fileName); } elseif (is_dir($fileName)) { wfRecursiveRemoveDir($fileName); } } if ($this->needsDB() && $this->db) { // Clean up open transactions while ($this->db->trxLevel() > 0) { $this->db->rollback(__METHOD__, 'flush'); } } DeferredUpdates::clearPendingUpdates(); ob_start('MediaWikiTestCase::wfResetOutputBuffersBarrier'); }
/** * @since 2.4 */ public static function clearPendingDeferredUpdates() { DeferredCallableUpdate::releasePendingUpdates(); \DeferredUpdates::clearPendingUpdates(); }
protected function setUp() { parent::setUp(); $this->called['setUp'] = true; $this->phpErrorLevel = intval(ini_get('error_reporting')); // Cleaning up temporary files foreach ($this->tmpFiles as $fileName) { if (is_file($fileName) || is_link($fileName)) { unlink($fileName); } elseif (is_dir($fileName)) { wfRecursiveRemoveDir($fileName); } } if ($this->needsDB() && $this->db) { // Clean up open transactions while ($this->db->trxLevel() > 0) { $this->db->rollback(); } // don't ignore DB errors $this->db->ignoreErrors(false); } DeferredUpdates::clearPendingUpdates(); }
protected function setUp() { parent::setUp(); $this->called['setUp'] = true; $this->phpErrorLevel = intval(ini_get('error_reporting')); // Cleaning up temporary files foreach ($this->tmpFiles as $fileName) { if (is_file($fileName) || is_link($fileName)) { unlink($fileName); } elseif (is_dir($fileName)) { wfRecursiveRemoveDir($fileName); } } if ($this->needsDB() && $this->db) { // Clean up open transactions while ($this->db->trxLevel() > 0) { $this->db->rollback(__METHOD__, 'flush'); } // Check for unsafe queries if ($this->db->getType() === 'mysql') { $this->db->query("SET sql_mode = 'STRICT_ALL_TABLES'"); } } DeferredUpdates::clearPendingUpdates(); ObjectCache::getMainWANInstance()->clearProcessCache(); // XXX: reset maintenance triggers // Hook into period lag checks which often happen in long-running scripts $lbFactory = MediaWikiServices::getInstance()->getDBLoadBalancerFactory(); Maintenance::setLBFactoryTriggers($lbFactory); ob_start('MediaWikiTestCase::wfResetOutputBuffersBarrier'); }