Don't use new MCR schema without using DB
authorAryeh Gregor <ayg@aryeh.name>
Tue, 13 Aug 2019 07:55:48 +0000 (10:55 +0300)
committerAryeh Gregor <ayg@aryeh.name>
Tue, 13 Aug 2019 14:05:24 +0000 (17:05 +0300)
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
tests/phpunit/includes/MovePageTest.php
tests/phpunit/includes/TitleTest.php

index 4544e9b..f546dc2 100644 (file)
@@ -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
index 9166666..31a0e79 100644 (file)
@@ -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;
        }
 
        /**
index a40b292..e8f0873 100644 (file)
@@ -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;
        }
 
        /**