From a3e8e22f9d89a3582653d4de3f78fec47b9676c0 Mon Sep 17 00:00:00 2001 From: Aryeh Gregor Date: Tue, 13 Aug 2019 10:55:48 +0300 Subject: [PATCH] Don't use new MCR schema without using DB If $wgContentHandlerUseDB is false and $wgMultiContentRevisionSchemaMigrationStage is not SCHEMA_COMPAT_OLD, RevisionStoreFactory::getRevisionStore() throws. This is coming up in some seemingly unrelated code changes, perhaps due to access of stale service objects, but I'm not sure because I can't reproduce locally. So this is a shot in the dark to fix it. Change-Id: Id29a62e1f537fa1b2016aac396773b728e238cda --- tests/phpunit/includes/MergeHistoryTest.php | 1 - tests/phpunit/includes/MovePageTest.php | 17 ++++++++++++++--- tests/phpunit/includes/TitleTest.php | 20 +++++++++++++++++--- 3 files changed, 31 insertions(+), 7 deletions(-) diff --git a/tests/phpunit/includes/MergeHistoryTest.php b/tests/phpunit/includes/MergeHistoryTest.php index 4544e9bed8..f546dc202b 100644 --- a/tests/phpunit/includes/MergeHistoryTest.php +++ b/tests/phpunit/includes/MergeHistoryTest.php @@ -27,7 +27,6 @@ class MergeHistoryTest extends MediaWikiTestCase { * @param string|bool $error Expected error for test (or true for no error) */ public function testIsValidMerge( $source, $dest, $timestamp, $error ) { - $this->setMwGlobals( 'wgContentHandlerUseDB', false ); if ( $timestamp === true ) { // Although this timestamp is after the latest timestamp of both pages, // MergeHistory should select the latest source timestamp up to this which should diff --git a/tests/phpunit/includes/MovePageTest.php b/tests/phpunit/includes/MovePageTest.php index 9166666543..31a0e79aa7 100644 --- a/tests/phpunit/includes/MovePageTest.php +++ b/tests/phpunit/includes/MovePageTest.php @@ -18,7 +18,11 @@ class MovePageTest extends MediaWikiTestCase { * @covers MovePage::isValidFileMove */ public function testIsValidMove( $old, $new, $error ) { - $this->setMwGlobals( 'wgContentHandlerUseDB', false ); + global $wgMultiContentRevisionSchemaMigrationStage; + if ( $wgMultiContentRevisionSchemaMigrationStage === SCHEMA_COMPAT_OLD ) { + // We can only set this to false with the old schema + $this->setMwGlobals( 'wgContentHandlerUseDB', false ); + } $mp = new MovePage( Title::newFromText( $old ), Title::newFromText( $new ) @@ -35,16 +39,23 @@ class MovePageTest extends MediaWikiTestCase { * This should be kept in sync with TitleTest::provideTestIsValidMoveOperation */ public static function provideIsValidMove() { - return [ + global $wgMultiContentRevisionSchemaMigrationStage; + $ret = [ // for MovePage::isValidMove [ 'Test', 'Test', 'selfmove' ], [ 'Special:FooBar', 'Test', 'immobile-source-namespace' ], [ 'Test', 'Special:FooBar', 'immobile-target-namespace' ], - [ 'MediaWiki:Common.js', 'Help:Some wikitext page', 'bad-target-model' ], [ 'Page', 'File:Test.jpg', 'nonfile-cannot-move-to-file' ], // for MovePage::isValidFileMove [ 'File:Test.jpg', 'Page', 'imagenocrossnamespace' ], ]; + if ( $wgMultiContentRevisionSchemaMigrationStage === SCHEMA_COMPAT_OLD ) { + // The error can only occur if $wgContentHandlerUseDB is false, which doesn't work with + // the new schema, so omit the test in that case + array_push( $ret, + [ 'MediaWiki:Common.js', 'Help:Some wikitext page', 'bad-target-model' ] ); + } + return $ret; } /** diff --git a/tests/phpunit/includes/TitleTest.php b/tests/phpunit/includes/TitleTest.php index a40b2921c4..e8f08732e8 100644 --- a/tests/phpunit/includes/TitleTest.php +++ b/tests/phpunit/includes/TitleTest.php @@ -296,9 +296,15 @@ class TitleTest extends MediaWikiTestCase { * @covers Title::isValidMoveOperation */ public function testIsValidMoveOperation( $source, $target, $expected ) { + global $wgMultiContentRevisionSchemaMigrationStage; + $this->hideDeprecated( 'Title::isValidMoveOperation' ); - $this->setMwGlobals( 'wgContentHandlerUseDB', false ); + if ( $wgMultiContentRevisionSchemaMigrationStage === SCHEMA_COMPAT_OLD ) { + // We can only set this to false with the old schema + $this->setMwGlobals( 'wgContentHandlerUseDB', false ); + } + $title = Title::newFromText( $source ); $nt = Title::newFromText( $target ); $errors = $title->isValidMoveOperation( $nt, false ); @@ -313,16 +319,24 @@ class TitleTest extends MediaWikiTestCase { } public static function provideTestIsValidMoveOperation() { - return [ + global $wgMultiContentRevisionSchemaMigrationStage; + $ret = [ // for Title::isValidMoveOperation [ 'Some page', '', 'badtitletext' ], [ 'Test', 'Test', 'selfmove' ], [ 'Special:FooBar', 'Test', 'immobile-source-namespace' ], [ 'Test', 'Special:FooBar', 'immobile-target-namespace' ], - [ 'MediaWiki:Common.js', 'Help:Some wikitext page', 'bad-target-model' ], [ 'Page', 'File:Test.jpg', 'nonfile-cannot-move-to-file' ], [ 'File:Test.jpg', 'Page', 'imagenocrossnamespace' ], ]; + if ( $wgMultiContentRevisionSchemaMigrationStage === SCHEMA_COMPAT_OLD ) { + // The error can only occur if $wgContentHandlerUseDB is false, which doesn't work with + // the new schema, so omit the test in that case + array_push( $ret, + [ 'MediaWiki:Common.js', 'Help:Some wikitext page', 'bad-target-model' ] + ); + } + return $ret; } /** -- 2.20.1