ActorMigration: Remove possibility of read-both
[lhc/web/wiklou.git] / tests / phpunit / includes / Revision / RevisionQueryInfoTest.php
index e852bec..7188cf5 100644 (file)
@@ -93,22 +93,14 @@ class RevisionQueryInfoTest extends MediaWikiTestCase {
                ];
        }
 
-       protected function getCompatActorQueryFields( $prefix, $tmp = false ) {
-               return [
-                       "{$prefix}_user" => "COALESCE( actor_{$prefix}_user.actor_user, {$prefix}_user )",
-                       "{$prefix}_user_text" => "COALESCE( actor_{$prefix}_user.actor_name, {$prefix}_user_text )",
-                       "{$prefix}_actor" => $tmp ?: "{$prefix}_actor",
-               ];
-       }
-
-       protected function getCompatActorJoins( $prefix ) {
+       protected function getNewActorJoins( $prefix ) {
                return [
                        "temp_{$prefix}_user" => [
-                               "LEFT JOIN",
+                               "JOIN",
                                "temp_{$prefix}_user.revactor_{$prefix} = {$prefix}_id",
                        ],
                        "actor_{$prefix}_user" => [
-                               "LEFT JOIN",
+                               "JOIN",
                                "actor_{$prefix}_user.actor_id = temp_{$prefix}_user.revactor_actor",
                        ],
                ];
@@ -163,7 +155,7 @@ class RevisionQueryInfoTest extends MediaWikiTestCase {
                        [
                                'wgMultiContentRevisionSchemaMigrationStage' => SCHEMA_COMPAT_NEW,
                                'wgCommentTableSchemaMigrationStage' => MIGRATION_NEW,
-                               'wgActorTableSchemaMigrationStage' => MIGRATION_NEW,
+                               'wgActorTableSchemaMigrationStage' => SCHEMA_COMPAT_NEW,
                        ],
                        [
                                'tables' => [
@@ -189,7 +181,7 @@ class RevisionQueryInfoTest extends MediaWikiTestCase {
                                'wgMultiContentRevisionSchemaMigrationStage'
                                        => SCHEMA_COMPAT_WRITE_BOTH | SCHEMA_COMPAT_READ_NEW,
                                'wgCommentTableSchemaMigrationStage' => MIGRATION_WRITE_NEW,
-                               'wgActorTableSchemaMigrationStage' => MIGRATION_WRITE_NEW,
+                               'wgActorTableSchemaMigrationStage' => SCHEMA_COMPAT_NEW,
                        ],
                        [
                                'tables' => [
@@ -199,13 +191,13 @@ class RevisionQueryInfoTest extends MediaWikiTestCase {
                                ],
                                'fields' => array_merge(
                                        $this->getArchiveQueryFields( false ),
-                                       $this->getCompatActorQueryFields( 'ar' ),
+                                       $this->getNewActorQueryFields( 'ar' ),
                                        $this->getCompatCommentQueryFields( 'ar' )
                                ),
                                'joins' => [
                                        'comment_ar_comment'
                                                => [ 'LEFT JOIN', 'comment_ar_comment.comment_id = ar_comment_id' ],
-                                       'actor_ar_user' => [ 'LEFT JOIN', 'actor_ar_user.actor_id = ar_actor' ],
+                                       'actor_ar_user' => [ 'JOIN', 'actor_ar_user.actor_id = ar_actor' ],
                                ],
                        ]
                ];
@@ -215,24 +207,22 @@ class RevisionQueryInfoTest extends MediaWikiTestCase {
                                'wgMultiContentRevisionSchemaMigrationStage'
                                        => SCHEMA_COMPAT_WRITE_BOTH | SCHEMA_COMPAT_READ_OLD,
                                'wgCommentTableSchemaMigrationStage' => MIGRATION_WRITE_BOTH,
-                               'wgActorTableSchemaMigrationStage' => MIGRATION_WRITE_BOTH,
+                               'wgActorTableSchemaMigrationStage' => SCHEMA_COMPAT_WRITE_BOTH | SCHEMA_COMPAT_READ_OLD,
                        ],
                        [
                                'tables' => [
                                        'archive',
-                                       'actor_ar_user' => 'actor',
                                        'comment_ar_comment' => 'comment',
                                ],
                                'fields' => array_merge(
                                        $this->getArchiveQueryFields( true ),
                                        $this->getContentHandlerQueryFields( 'ar' ),
-                                       $this->getCompatActorQueryFields( 'ar' ),
+                                       $this->getOldActorQueryFields( 'ar' ),
                                        $this->getCompatCommentQueryFields( 'ar' )
                                ),
                                'joins' => [
                                        'comment_ar_comment'
                                                => [ 'LEFT JOIN', 'comment_ar_comment.comment_id = ar_comment_id' ],
-                                       'actor_ar_user' => [ 'LEFT JOIN', 'actor_ar_user.actor_id = ar_actor' ],
                                ],
                        ]
                ];
@@ -241,7 +231,7 @@ class RevisionQueryInfoTest extends MediaWikiTestCase {
                                'wgContentHandlerUseDB' => false,
                                'wgMultiContentRevisionSchemaMigrationStage' => SCHEMA_COMPAT_OLD,
                                'wgCommentTableSchemaMigrationStage' => MIGRATION_OLD,
-                               'wgActorTableSchemaMigrationStage' => MIGRATION_OLD,
+                               'wgActorTableSchemaMigrationStage' => SCHEMA_COMPAT_OLD,
                        ],
                        [
                                'tables' => [
@@ -264,7 +254,7 @@ class RevisionQueryInfoTest extends MediaWikiTestCase {
                                'wgContentHandlerUseDB' => true,
                                'wgMultiContentRevisionSchemaMigrationStage' => SCHEMA_COMPAT_NEW,
                                'wgCommentTableSchemaMigrationStage' => MIGRATION_NEW,
-                               'wgActorTableSchemaMigrationStage' => MIGRATION_NEW,
+                               'wgActorTableSchemaMigrationStage' => SCHEMA_COMPAT_NEW,
                        ],
                        [ 'page', 'user' ],
                        [
@@ -309,7 +299,7 @@ class RevisionQueryInfoTest extends MediaWikiTestCase {
                                'wgMultiContentRevisionSchemaMigrationStage'
                                        => SCHEMA_COMPAT_WRITE_BOTH | SCHEMA_COMPAT_READ_NEW,
                                'wgCommentTableSchemaMigrationStage' => MIGRATION_WRITE_NEW,
-                               'wgActorTableSchemaMigrationStage' => MIGRATION_WRITE_NEW,
+                               'wgActorTableSchemaMigrationStage' => SCHEMA_COMPAT_WRITE_BOTH | SCHEMA_COMPAT_READ_NEW,
                        ],
                        [ 'page', 'user' ],
                        [
@@ -326,7 +316,7 @@ class RevisionQueryInfoTest extends MediaWikiTestCase {
                                        $this->getRevisionQueryFields( false ),
                                        $this->getPageQueryFields(),
                                        $this->getUserQueryFields(),
-                                       $this->getCompatActorQueryFields( 'rev', 'temp_rev_user.revactor_actor' ),
+                                       $this->getNewActorQueryFields( 'rev', 'temp_rev_user.revactor_actor' ),
                                        $this->getCompatCommentQueryFields( 'rev' )
                                ),
                                'joins' => array_merge(
@@ -335,12 +325,12 @@ class RevisionQueryInfoTest extends MediaWikiTestCase {
                                                'user' => [
                                                        'LEFT JOIN',
                                                        [
-                                                               'COALESCE( actor_rev_user.actor_user, rev_user ) != 0',
-                                                               'user_id = COALESCE( actor_rev_user.actor_user, rev_user )'
+                                                               'actor_rev_user.actor_user != 0',
+                                                               'user_id = actor_rev_user.actor_user',
                                                        ]
                                                ],
                                        ],
-                                       $this->getCompatActorJoins( 'rev' ),
+                                       $this->getNewActorJoins( 'rev' ),
                                        $this->getCompatCommentJoins( 'rev' )
                                ),
                        ]
@@ -351,7 +341,7 @@ class RevisionQueryInfoTest extends MediaWikiTestCase {
                                'wgMultiContentRevisionSchemaMigrationStage'
                                        => SCHEMA_COMPAT_WRITE_BOTH | SCHEMA_COMPAT_READ_NEW,
                                'wgCommentTableSchemaMigrationStage' => MIGRATION_WRITE_NEW,
-                               'wgActorTableSchemaMigrationStage' => MIGRATION_WRITE_NEW,
+                               'wgActorTableSchemaMigrationStage' => SCHEMA_COMPAT_WRITE_BOTH | SCHEMA_COMPAT_READ_NEW,
                        ],
                        [ 'page', 'user' ],
                        [
@@ -368,7 +358,7 @@ class RevisionQueryInfoTest extends MediaWikiTestCase {
                                        $this->getRevisionQueryFields( false ),
                                        $this->getPageQueryFields(),
                                        $this->getUserQueryFields(),
-                                       $this->getCompatActorQueryFields( 'rev', 'temp_rev_user.revactor_actor' ),
+                                       $this->getNewActorQueryFields( 'rev', 'temp_rev_user.revactor_actor' ),
                                        $this->getCompatCommentQueryFields( 'rev' )
                                ),
                                'joins' => array_merge(
@@ -377,12 +367,12 @@ class RevisionQueryInfoTest extends MediaWikiTestCase {
                                                'user' => [
                                                        'LEFT JOIN',
                                                        [
-                                                               'COALESCE( actor_rev_user.actor_user, rev_user ) != 0',
-                                                               'user_id = COALESCE( actor_rev_user.actor_user, rev_user )'
+                                                               'actor_rev_user.actor_user != 0',
+                                                               'user_id = actor_rev_user.actor_user'
                                                        ]
                                                ],
                                        ],
-                                       $this->getCompatActorJoins( 'rev' ),
+                                       $this->getNewActorJoins( 'rev' ),
                                        $this->getCompatCommentJoins( 'rev' )
                                ),
                        ]
@@ -393,25 +383,22 @@ class RevisionQueryInfoTest extends MediaWikiTestCase {
                                'wgMultiContentRevisionSchemaMigrationStage'
                                        => SCHEMA_COMPAT_WRITE_BOTH | SCHEMA_COMPAT_READ_OLD,
                                'wgCommentTableSchemaMigrationStage' => MIGRATION_WRITE_BOTH,
-                               'wgActorTableSchemaMigrationStage' => MIGRATION_WRITE_BOTH,
+                               'wgActorTableSchemaMigrationStage' => SCHEMA_COMPAT_WRITE_BOTH | SCHEMA_COMPAT_READ_OLD,
                        ],
                        [],
                        [
                                'tables' => [
                                        'revision',
-                                       'temp_rev_user' => 'revision_actor_temp',
                                        'temp_rev_comment' => 'revision_comment_temp',
-                                       'actor_rev_user' => 'actor',
                                        'comment_rev_comment' => 'comment',
                                ],
                                'fields' => array_merge(
                                        $this->getRevisionQueryFields( true ),
                                        $this->getContentHandlerQueryFields( 'rev' ),
-                                       $this->getCompatActorQueryFields( 'rev', 'temp_rev_user.revactor_actor' ),
+                                       $this->getOldActorQueryFields( 'rev', 'temp_rev_user.revactor_actor' ),
                                        $this->getCompatCommentQueryFields( 'rev' )
                                ),
                        'joins' => array_merge(
-                               $this->getCompatActorJoins( 'rev' ),
                                $this->getCompatCommentJoins( 'rev' )
                        ),
                        ]
@@ -422,7 +409,7 @@ class RevisionQueryInfoTest extends MediaWikiTestCase {
                                'wgMultiContentRevisionSchemaMigrationStage'
                                        => SCHEMA_COMPAT_WRITE_BOTH | SCHEMA_COMPAT_READ_OLD,
                                'wgCommentTableSchemaMigrationStage' => MIGRATION_WRITE_BOTH,
-                               'wgActorTableSchemaMigrationStage' => MIGRATION_WRITE_BOTH,
+                               'wgActorTableSchemaMigrationStage' => SCHEMA_COMPAT_WRITE_BOTH | SCHEMA_COMPAT_READ_OLD,
                        ],
                        [ 'page', 'user' ],
                        [
@@ -430,9 +417,7 @@ class RevisionQueryInfoTest extends MediaWikiTestCase {
                                        'revision',
                                        'page',
                                        'user',
-                                       'temp_rev_user' => 'revision_actor_temp',
                                        'temp_rev_comment' => 'revision_comment_temp',
-                                       'actor_rev_user' => 'actor',
                                        'comment_rev_comment' => 'comment',
                                ],
                                'fields' => array_merge(
@@ -440,7 +425,7 @@ class RevisionQueryInfoTest extends MediaWikiTestCase {
                                        $this->getContentHandlerQueryFields( 'rev' ),
                                        $this->getUserQueryFields(),
                                        $this->getPageQueryFields(),
-                                       $this->getCompatActorQueryFields( 'rev', 'temp_rev_user.revactor_actor' ),
+                                       $this->getOldActorQueryFields( 'rev', 'temp_rev_user.revactor_actor' ),
                                        $this->getCompatCommentQueryFields( 'rev' )
                                ),
                                'joins' => array_merge(
@@ -449,12 +434,11 @@ class RevisionQueryInfoTest extends MediaWikiTestCase {
                                                'user' => [
                                                        'LEFT JOIN',
                                                        [
-                                                               'COALESCE( actor_rev_user.actor_user, rev_user ) != 0',
-                                                               'user_id = COALESCE( actor_rev_user.actor_user, rev_user )'
+                                                               'rev_user != 0',
+                                                               'user_id = rev_user'
                                                        ]
                                                ],
                                        ],
-                                       $this->getCompatActorJoins( 'rev' ),
                                        $this->getCompatCommentJoins( 'rev' )
                                ),
                        ]
@@ -464,7 +448,7 @@ class RevisionQueryInfoTest extends MediaWikiTestCase {
                                'wgContentHandlerUseDB' => true,
                                'wgMultiContentRevisionSchemaMigrationStage' => SCHEMA_COMPAT_OLD,
                                'wgCommentTableSchemaMigrationStage' => MIGRATION_OLD,
-                               'wgActorTableSchemaMigrationStage' => MIGRATION_OLD,
+                               'wgActorTableSchemaMigrationStage' => SCHEMA_COMPAT_OLD,
                        ],
                        [],
                        [
@@ -483,7 +467,7 @@ class RevisionQueryInfoTest extends MediaWikiTestCase {
                                'wgContentHandlerUseDB' => true,
                                'wgMultiContentRevisionSchemaMigrationStage' => SCHEMA_COMPAT_OLD,
                                'wgCommentTableSchemaMigrationStage' => MIGRATION_OLD,
-                               'wgActorTableSchemaMigrationStage' => MIGRATION_OLD,
+                               'wgActorTableSchemaMigrationStage' => SCHEMA_COMPAT_OLD,
                        ],
                        [ 'page', 'user' ],
                        [
@@ -507,7 +491,7 @@ class RevisionQueryInfoTest extends MediaWikiTestCase {
                                'wgContentHandlerUseDB' => false,
                                'wgMultiContentRevisionSchemaMigrationStage' => SCHEMA_COMPAT_OLD,
                                'wgCommentTableSchemaMigrationStage' => MIGRATION_OLD,
-                               'wgActorTableSchemaMigrationStage' => MIGRATION_OLD,
+                               'wgActorTableSchemaMigrationStage' => SCHEMA_COMPAT_OLD,
                        ],
                        [],
                        [
@@ -525,7 +509,7 @@ class RevisionQueryInfoTest extends MediaWikiTestCase {
                                'wgContentHandlerUseDB' => false,
                                'wgMultiContentRevisionSchemaMigrationStage' => SCHEMA_COMPAT_OLD,
                                'wgCommentTableSchemaMigrationStage' => MIGRATION_OLD,
-                               'wgActorTableSchemaMigrationStage' => MIGRATION_OLD,
+                               'wgActorTableSchemaMigrationStage' => SCHEMA_COMPAT_OLD,
                        ],
                        [ 'page' ],
                        [
@@ -546,7 +530,7 @@ class RevisionQueryInfoTest extends MediaWikiTestCase {
                                'wgContentHandlerUseDB' => false,
                                'wgMultiContentRevisionSchemaMigrationStage' => SCHEMA_COMPAT_OLD,
                                'wgCommentTableSchemaMigrationStage' => MIGRATION_OLD,
-                               'wgActorTableSchemaMigrationStage' => MIGRATION_OLD,
+                               'wgActorTableSchemaMigrationStage' => SCHEMA_COMPAT_OLD,
                        ],
                        [ 'user' ],
                        [
@@ -567,7 +551,7 @@ class RevisionQueryInfoTest extends MediaWikiTestCase {
                                'wgContentHandlerUseDB' => false,
                                'wgMultiContentRevisionSchemaMigrationStage' => SCHEMA_COMPAT_OLD,
                                'wgCommentTableSchemaMigrationStage' => MIGRATION_OLD,
-                               'wgActorTableSchemaMigrationStage' => MIGRATION_OLD,
+                               'wgActorTableSchemaMigrationStage' => SCHEMA_COMPAT_OLD,
                        ],
                        [ 'text' ],
                        [
@@ -588,7 +572,7 @@ class RevisionQueryInfoTest extends MediaWikiTestCase {
                                'wgContentHandlerUseDB' => false,
                                'wgMultiContentRevisionSchemaMigrationStage' => SCHEMA_COMPAT_OLD,
                                'wgCommentTableSchemaMigrationStage' => MIGRATION_OLD,
-                               'wgActorTableSchemaMigrationStage' => MIGRATION_OLD,
+                               'wgActorTableSchemaMigrationStage' => SCHEMA_COMPAT_OLD,
                        ],
                        [ 'text', 'page', 'user' ],
                        [
@@ -850,7 +834,7 @@ class RevisionQueryInfoTest extends MediaWikiTestCase {
                        [
                                'wgContentHandlerUseDB' => true,
                                'wgCommentTableSchemaMigrationStage' => MIGRATION_WRITE_BOTH,
-                               'wgActorTableSchemaMigrationStage' => MIGRATION_WRITE_BOTH,
+                               'wgActorTableSchemaMigrationStage' => SCHEMA_COMPAT_WRITE_BOTH | SCHEMA_COMPAT_READ_OLD,
                        ],
                        'fields' => array_merge(
                                [
@@ -878,7 +862,7 @@ class RevisionQueryInfoTest extends MediaWikiTestCase {
                        [
                                'wgContentHandlerUseDB' => false,
                                'wgCommentTableSchemaMigrationStage' => MIGRATION_OLD,
-                               'wgActorTableSchemaMigrationStage' => MIGRATION_OLD,
+                               'wgActorTableSchemaMigrationStage' => SCHEMA_COMPAT_OLD,
                        ],
                        'fields' => array_merge(
                                [
@@ -905,7 +889,7 @@ class RevisionQueryInfoTest extends MediaWikiTestCase {
                        [
                                'wgContentHandlerUseDB' => true,
                                'wgCommentTableSchemaMigrationStage' => MIGRATION_WRITE_BOTH,
-                               'wgActorTableSchemaMigrationStage' => MIGRATION_WRITE_BOTH,
+                               'wgActorTableSchemaMigrationStage' => SCHEMA_COMPAT_WRITE_BOTH | SCHEMA_COMPAT_READ_OLD,
                        ],
                        'fields' => array_merge(
                                [
@@ -934,7 +918,7 @@ class RevisionQueryInfoTest extends MediaWikiTestCase {
                        [
                                'wgContentHandlerUseDB' => false,
                                'wgCommentTableSchemaMigrationStage' => MIGRATION_OLD,
-                               'wgActorTableSchemaMigrationStage' => MIGRATION_OLD,
+                               'wgActorTableSchemaMigrationStage' => SCHEMA_COMPAT_OLD,
                        ],
                        'fields' => array_merge(
                                [
@@ -986,7 +970,7 @@ class RevisionQueryInfoTest extends MediaWikiTestCase {
         */
        public function testRevisionUserJoinCond() {
                $this->hideDeprecated( 'Revision::userJoinCond' );
-               $this->setMwGlobals( 'wgActorTableSchemaMigrationStage', MIGRATION_OLD );
+               $this->setMwGlobals( 'wgActorTableSchemaMigrationStage', SCHEMA_COMPAT_OLD );
                $this->overrideMwServices();
                $this->assertEquals(
                        [ 'LEFT JOIN', [ 'rev_user != 0', 'user_id = rev_user' ] ],