$this->showOutput = isset( $options['show-output'] );
+ if ( isset( $options['filter'] ) ) {
+ $options['regex'] = $options['filter'];
+ }
if ( isset( $options['regex'] ) ) {
if ( isset( $options['record'] ) ) {
$wgUser, $wgLang, $wgOut, $wgRequest, $wgStyleDirectory, $wgEnableParserCache,
$wgNamespaceAliases, $wgNamespaceProtection, $wgLocalFileRepo,
$parserMemc, $wgThumbnailScriptPath, $wgScriptPath,
- $wgArticlePath, $wgStyleSheetPath, $wgScript, $wgStylePath, $wgExtensionAssetsPath;
+ $wgArticlePath, $wgStyleSheetPath, $wgScript, $wgStylePath, $wgExtensionAssetsPath,
+ $wgMainCacheType, $wgMessageCacheType, $wgParserCacheType, $wgLockManagers;
$wgScript = '/index.php';
$wgScriptPath = '/';
$wgStylePath = '/skins';
$wgExtensionAssetsPath = '/extensions';
$wgThumbnailScriptPath = false;
+ $wgLockManagers = array( array(
+ 'name' => 'fsLockManager',
+ 'class' => 'FSLockManager',
+ 'lockDirectory' => wfTempDir() . '/test-repo/lockdir',
+ ) );
$wgLocalFileRepo = array(
- 'class' => 'LocalRepo',
- 'name' => 'local',
- 'directory' => wfTempDir() . '/test-repo',
- 'url' => 'http://example.com/images',
- 'deletedDir' => wfTempDir() . '/test-repo/delete',
- 'hashLevels' => 2,
+ 'class' => 'LocalRepo',
+ 'name' => 'local',
+ 'url' => 'http://example.com/images',
+ 'hashLevels' => 2,
'transformVia404' => false,
+ 'backend' => new FSFileBackend( array(
+ 'name' => 'local-backend',
+ 'lockManager' => 'fsLockManager',
+ 'containerPaths' => array(
+ 'local-public' => wfTempDir() . '/test-repo/public',
+ 'local-thumb' => wfTempDir() . '/test-repo/thumb',
+ 'local-temp' => wfTempDir() . '/test-repo/temp',
+ 'local-deleted' => wfTempDir() . '/test-repo/deleted',
+ )
+ ) )
);
$wgNamespaceProtection[NS_MEDIAWIKI] = 'editinterface';
$wgNamespaceAliases['Image'] = NS_FILE;
$wgNamespaceAliases['Image_talk'] = NS_FILE_TALK;
+ // XXX: tests won't run without this (for CACHE_DB)
+ if ( $wgMainCacheType === CACHE_DB ) {
+ $wgMainCacheType = CACHE_NONE;
+ }
+ if ( $wgMessageCacheType === CACHE_DB ) {
+ $wgMessageCacheType = CACHE_NONE;
+ }
+ if ( $wgParserCacheType === CACHE_DB ) {
+ $wgParserCacheType = CACHE_NONE;
+ }
$wgEnableParserCache = false;
DeferredUpdates::clearPendingUpdates();
- $wgMemc = wfGetMainCache();
+ $wgMemc = wfGetMainCache(); // checks $wgMainCacheType
$messageMemc = wfGetMessageCacheStorage();
$parserMemc = wfGetParserCacheStorage();
// $wgContLang = new StubContLang;
$wgUser = new User;
$context = new RequestContext;
- $wgLang = $context->getLang();
+ $wgLang = $context->getLanguage();
$wgOut = $context->getOutput();
$wgParser = new StubObject( 'wgParser', $wgParserConf['class'], array( $wgParserConf ) );
$wgRequest = $context->getRequest();
}
$opts = $this->parseOptions( $opts );
- $this->setupGlobals( $opts, $config );
+ $context = $this->setupGlobals( $opts, $config );
- $user = new User();
- $options = ParserOptions::newFromUser( $user );
+ $user = $context->getUser();
+ $options = ParserOptions::newFromContext( $context );
if ( isset( $opts['title'] ) ) {
$titleText = $opts['title'];
if ( isset( $opts['ill'] ) ) {
$out = $this->tidy( implode( ' ', $output->getLanguageLinks() ) );
} elseif ( isset( $opts['cat'] ) ) {
- global $wgOut;
-
- $wgOut->addCategoryLinks( $output->getCategories() );
- $cats = $wgOut->getCategoryLinks();
+ $outputPage = $context->getOutput();
+ $outputPage->addCategoryLinks( $output->getCategories() );
+ $cats = $outputPage->getCategoryLinks();
if ( isset( $cats['normal'] ) ) {
$out = $this->tidy( implode( ' ', $cats['normal'] ) );
'wgScriptPath' => '/',
'wgArticlePath' => '/wiki/$1',
'wgActionPaths' => array(),
+ 'wgLockManagers' => array(
+ 'name' => 'fsLockManager',
+ 'class' => 'FSLockManager',
+ 'lockDirectory' => $this->uploadDir . '/lockdir',
+ ),
'wgLocalFileRepo' => array(
'class' => 'LocalRepo',
'name' => 'local',
- 'directory' => $this->uploadDir,
'url' => 'http://example.com/images',
'hashLevels' => 2,
'transformVia404' => false,
+ 'backend' => new FSFileBackend( array(
+ 'name' => 'local-backend',
+ 'lockManager' => 'fsLockManager',
+ 'containerPaths' => array(
+ 'local-public' => $this->uploadDir,
+ 'local-thumb' => $this->uploadDir . '/thumb',
+ 'local-temp' => $this->uploadDir . '/temp',
+ 'local-deleted' => $this->uploadDir . '/delete',
+ )
+ ) )
),
'wgEnableUploads' => self::getOptionValue( 'wgEnableUploads', $opts, true ),
'wgStylePath' => '/skins',
$GLOBALS['wgMemc'] = new EmptyBagOStuff;
$context = new RequestContext();
- $GLOBALS['wgLang'] = $context->getLang();
+ $GLOBALS['wgLang'] = $context->getLanguage();
$GLOBALS['wgOut'] = $context->getOutput();
$GLOBALS['wgUser'] = new User();
$wgHooks['ParserGetVariableValueTs'][] = 'ParserTest::getFakeTimestamp';
MagicWord::clearCache();
+
+ return $context;
}
/**
* Some of these probably aren't necessary.
*/
private function listTables() {
- $tables = array( 'user', 'user_properties', 'page', 'page_restrictions',
+ $tables = array( 'user', 'user_properties', 'user_former_groups', 'page', 'page_restrictions',
'protected_titles', 'revision', 'text', 'pagelinks', 'imagelinks',
'categorylinks', 'templatelinks', 'externallinks', 'langlinks', 'iwlinks',
'site_stats', 'hitcounter', 'ipblocks', 'image', 'oldimage',
'archive', 'user_groups', 'page_props', 'category', 'msg_resource', 'msg_resource_links'
);
- if ( in_array( $this->db->getType(), array( 'mysql', 'sqlite', 'oracle' ) ) )
+ if ( in_array( $this->db->getType(), array( 'mysql', 'sqlite', 'oracle' ) ) ) {
array_push( $tables, 'searchindex' );
+ }
// Allow extensions to add to the list of tables to duplicate;
// may be necessary if they hook into page save or other code
}
$temporary = $this->useTemporaryTables || $dbType == 'postgres';
- $tables = $this->listTables();
$prefix = $dbType != 'oracle' ? 'parsertest_' : 'pt_';
$this->dbClone = new CloneDatabase( $this->db, $this->listTables(), $prefix );
$this->dbClone->useTemporaryTables( $temporary );
$this->dbClone->cloneTableStructure();
- if ( $dbType == 'oracle' )
- $this->db->query( 'BEGIN FILL_WIKI_INFO; END;' );
-
if ( $dbType == 'oracle' ) {
+ $this->db->query( 'BEGIN FILL_WIKI_INFO; END;' );
# Insert 0 user to prevent FK violations
# Anonymous user
'iw_local' => 1 ),
) );
-
# Update certain things in site_stats
$this->db->insert( 'site_stats', array( 'ss_row_id' => 1, 'ss_images' => 2, 'ss_good_articles' => 1 ) );
$this->databaseSetupDone = false;
if ( $this->useTemporaryTables ) {
+ if( $this->db->getType() == 'sqlite' ) {
+ # Under SQLite the searchindex table is virtual and need
+ # to be explicitly destroyed. See bug 29912
+ # See also MediaWikiTestCase::destroyDB()
+ wfDebug( __METHOD__ . " explicitly destroying sqlite virtual table parsertest_searchindex\n" );
+ $this->db->query( "DROP TABLE `parsertest_searchindex`" );
+ }
# Don't need to do anything
$this->teardownGlobals();
return;
*/
private function teardownGlobals() {
RepoGroup::destroySingleton();
+ FileBackendGroup::destroySingleton();
+ LockManagerGroup::destroySingleton();
LinkCache::singleton()->clear();
foreach ( $this->savedGlobals as $var => $val ) {
* @param $name String: the title, including any prefix
* @param $text String: the article text
* @param $line Integer: the input line number, for reporting errors
+ * @param $ignoreDuplicate Boolean: whether to silently ignore duplicate pages
*/
- static public function addArticle( $name, $text, $line = 'unknown' ) {
+ static public function addArticle( $name, $text, $line = 'unknown', $ignoreDuplicate = '' ) {
global $wgCapitalLinks;
- $text = self::chomp($text);
-
$oldCapitalLinks = $wgCapitalLinks;
$wgCapitalLinks = true; // We only need this from SetupGlobals() See r70917#c8637
+ $text = self::chomp( $text );
$name = self::chomp( $name );
+
$title = Title::newFromText( $name );
if ( is_null( $title ) ) {
- throw new MWException( "invalid title ('$name' => '$title') at line $line\n" );
+ throw new MWException( "invalid title '$name' at line $line\n" );
}
- $aid = $title->getArticleID( Title::GAID_FOR_UPDATE );
+ $page = WikiPage::factory( $title );
+ $page->loadPageData( 'fromdbmaster' );
- if ( $aid != 0 ) {
- throw new MWException( "duplicate article '$name' at line $line\n" );
+ if ( $page->exists() ) {
+ if ( $ignoreDuplicate == 'ignoreduplicate' ) {
+ return;
+ } else {
+ throw new MWException( "duplicate article '$name' at line $line\n" );
+ }
}
- $art = new Article( $title );
- $art->doEdit( $text, '', EDIT_NEW );
+ $page->doEdit( $text, '', EDIT_NEW );
$wgCapitalLinks = $oldCapitalLinks;
}
return true;
}
- /*
+ /**
* Run the "tidy" command on text if the $wgUseTidy
* global is true
*