// Changing wgExtraNamespaces invalidates caches in MWNamespace and
// any live Language object, both on setup and teardown
$reset = function () {
- MWNamespace::getCanonicalNamespaces( true );
+ MWNamespace::clearCaches();
$GLOBALS['wgContLang']->resetNamespaces();
};
$setup[] = $reset;
public function meetsRequirements( $requirements ) {
foreach ( $requirements as $requirement ) {
switch ( $requirement['type'] ) {
- case 'hook':
- $ok = $this->requireHook( $requirement['name'] );
- break;
- case 'functionHook':
- $ok = $this->requireFunctionHook( $requirement['name'] );
- break;
- case 'transparentHook':
- $ok = $this->requireTransparentHook( $requirement['name'] );
- break;
+ case 'hook':
+ $ok = $this->requireHook( $requirement['name'] );
+ break;
+ case 'functionHook':
+ $ok = $this->requireFunctionHook( $requirement['name'] );
+ break;
+ case 'transparentHook':
+ $ok = $this->requireTransparentHook( $requirement['name'] );
+ break;
}
if ( !$ok ) {
return false;
$out = $parser->getPreloadText( $test['input'], $title, $options );
} else {
$output = $parser->parse( $test['input'], $title, $options, true, true, 1337 );
- $output->setTOCEnabled( !isset( $opts['notoc'] ) );
- $out = $output->getText();
+ $out = $output->getText( [
+ 'allowTOC' => !isset( $opts['notoc'] )
+ ] );
if ( isset( $opts['tidy'] ) ) {
$out = preg_replace( '/\s+$/', '', $out );
}
* @return array
*/
private function listTables() {
+ global $wgCommentTableSchemaMigrationStage;
+
$tables = [ 'user', 'user_properties', 'user_former_groups', 'page', 'page_restrictions',
'protected_titles', 'revision', 'ip_changes', 'text', 'pagelinks', 'imagelinks',
'categorylinks', 'templatelinks', 'externallinks', 'langlinks', 'iwlinks',
'archive', 'user_groups', 'page_props', 'category'
];
+ if ( $wgCommentTableSchemaMigrationStage >= MIGRATION_WRITE_BOTH ) {
+ // The new tables for comments are in use
+ $tables[] = 'comment';
+ $tables[] = 'revision_comment_temp';
+ $tables[] = 'image_comment_temp';
+ }
+
if ( in_array( $this->db->getType(), [ 'mysql', 'sqlite', 'oracle' ] ) ) {
array_push( $tables, 'searchindex' );
}
throw new MWException( "invalid title '$name' at $file:$line\n" );
}
+ $newContent = ContentHandler::makeContent( $text, $title );
+
$page = WikiPage::factory( $title );
$page->loadPageData( 'fromdbmaster' );
if ( $page->exists() ) {
- throw new MWException( "duplicate article '$name' at $file:$line\n" );
+ $content = $page->getContent( Revision::RAW );
+ // Only reject the title, if the content/content model is different.
+ // This makes it easier to create Template:(( or Template:)) in different extensions
+ if ( $newContent->equals( $content ) ) {
+ return;
+ }
+ throw new MWException(
+ "duplicate article '$name' with different content at $file:$line\n"
+ );
}
// Use mock parser, to make debugging of actual parser tests simpler.
$restore = $this->executeSetupSnippets( [ 'wgParser' => new ParserTestMockParser ] );
try {
$status = $page->doEditContent(
- ContentHandler::makeContent( $text, $title ),
+ $newContent,
'',
EDIT_NEW | EDIT_INTERNAL
);