$wgNamespaceAliases, $wgNamespaceProtection, $wgLocalFileRepo,
$parserMemc, $wgThumbnailScriptPath, $wgScriptPath,
$wgArticlePath, $wgStyleSheetPath, $wgScript, $wgStylePath, $wgExtensionAssetsPath,
- $wgMainCacheType, $wgMessageCacheType, $wgParserCacheType;
+ $wgMainCacheType, $wgMessageCacheType, $wgParserCacheType, $wgLockManagers;
$wgScript = '/index.php';
$wgScriptPath = '/';
$wgStylePath = '/skins';
$wgExtensionAssetsPath = '/extensions';
$wgThumbnailScriptPath = false;
- $backend = new FSFileBackend( array(
- 'name' => 'local-backend',
- 'lockManager' => 'fsLockManager',
- 'containerPaths' => array(
- 'images-public' => wfTempDir() . '/test-repo/public',
- 'images-thumb' => wfTempDir() . '/test-repo/thumb',
- 'images-temp' => wfTempDir() . '/test-repo/temp',
- 'images-deleted' => wfTempDir() . '/test-repo/delete',
- )
+ $wgLockManagers = array( array(
+ 'name' => 'fsLockManager',
+ 'class' => 'FSLockManager',
+ 'lockDirectory' => wfTempDir() . '/test-repo/lockdir',
) );
$wgLocalFileRepo = array(
'class' => 'LocalRepo',
'url' => 'http://example.com/images',
'hashLevels' => 2,
'transformVia404' => false,
- 'backend' => $backend,
- 'zones' => array( 'deleted' => array(
- 'container' => 'images-deleted', 'directory' => '' ) )
+ '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;
'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',
$this->savedGlobals = array();
+ /** @since 1.20 */
+ wfRunHooks( 'ParserTestGlobals', array( &$settings ) );
+
foreach ( $settings as $var => $val ) {
if ( array_key_exists( $var, $GLOBALS ) ) {
$this->savedGlobals[$var] = $GLOBALS[$var];
* 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',
'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 ) );
*/
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" );
+ }
}
- $page = WikiPage::factory( $title );
$page->doEdit( $text, '', EDIT_NEW );
$wgCapitalLinks = $oldCapitalLinks;