Join slot and content tables when dumping XML
[lhc/web/wiklou.git] / tests / phpunit / includes / Revision / RevisionQueryInfoTest.php
index e852bec..57619c5 100644 (file)
@@ -1,4 +1,5 @@
 <?php
+
 namespace MediaWiki\Tests\Revision;
 
 use MediaWiki\MediaWikiServices;
@@ -52,23 +53,6 @@ class RevisionQueryInfoTest extends MediaWikiTestCase {
                return $fields;
        }
 
-       protected function getOldCommentQueryFields( $prefix ) {
-               return [
-                       "{$prefix}_comment_text" => "{$prefix}_comment",
-                       "{$prefix}_comment_data" => 'NULL',
-                       "{$prefix}_comment_cid" => 'NULL',
-               ];
-       }
-
-       protected function getCompatCommentQueryFields( $prefix ) {
-               return [
-                       "{$prefix}_comment_text"
-                               => "COALESCE( comment_{$prefix}_comment.comment_text, {$prefix}_comment )",
-                       "{$prefix}_comment_data" => "comment_{$prefix}_comment.comment_data",
-                       "{$prefix}_comment_cid" => "comment_{$prefix}_comment.comment_id",
-               ];
-       }
-
        protected function getNewCommentQueryFields( $prefix ) {
                return [
                        "{$prefix}_comment_text" => "comment_{$prefix}_comment.comment_text",
@@ -93,40 +77,19 @@ 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",
                        ],
                ];
        }
 
-       protected function getCompatCommentJoins( $prefix ) {
-               return [
-                       "temp_{$prefix}_comment" => [
-                               "LEFT JOIN",
-                               "temp_{$prefix}_comment.revcomment_{$prefix} = {$prefix}_id",
-                       ],
-                       "comment_{$prefix}_comment" => [
-                               "LEFT JOIN",
-                               "comment_{$prefix}_comment.comment_id = temp_{$prefix}_comment.revcomment_comment_id",
-                       ],
-               ];
-       }
-
        protected function getTextQueryFields() {
                return [
                        'old_text',
@@ -162,8 +125,7 @@ class RevisionQueryInfoTest extends MediaWikiTestCase {
                yield 'MCR, comment, actor' => [
                        [
                                'wgMultiContentRevisionSchemaMigrationStage' => SCHEMA_COMPAT_NEW,
-                               'wgCommentTableSchemaMigrationStage' => MIGRATION_NEW,
-                               'wgActorTableSchemaMigrationStage' => MIGRATION_NEW,
+                               'wgActorTableSchemaMigrationStage' => SCHEMA_COMPAT_NEW,
                        ],
                        [
                                'tables' => [
@@ -188,8 +150,7 @@ class RevisionQueryInfoTest extends MediaWikiTestCase {
                                'wgContentHandlerUseDB' => true,
                                'wgMultiContentRevisionSchemaMigrationStage'
                                        => SCHEMA_COMPAT_WRITE_BOTH | SCHEMA_COMPAT_READ_NEW,
-                               'wgCommentTableSchemaMigrationStage' => MIGRATION_WRITE_NEW,
-                               'wgActorTableSchemaMigrationStage' => MIGRATION_WRITE_NEW,
+                               'wgActorTableSchemaMigrationStage' => SCHEMA_COMPAT_NEW,
                        ],
                        [
                                'tables' => [
@@ -199,13 +160,13 @@ class RevisionQueryInfoTest extends MediaWikiTestCase {
                                ],
                                'fields' => array_merge(
                                        $this->getArchiveQueryFields( false ),
-                                       $this->getCompatActorQueryFields( 'ar' ),
-                                       $this->getCompatCommentQueryFields( 'ar' )
+                                       $this->getNewActorQueryFields( 'ar' ),
+                                       $this->getNewCommentQueryFields( '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' ],
+                                               => [ 'JOIN', 'comment_ar_comment.comment_id = ar_comment_id' ],
+                                       'actor_ar_user' => [ 'JOIN', 'actor_ar_user.actor_id = ar_actor' ],
                                ],
                        ]
                ];
@@ -214,25 +175,22 @@ class RevisionQueryInfoTest extends MediaWikiTestCase {
                                'wgContentHandlerUseDB' => true,
                                '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->getCompatCommentQueryFields( 'ar' )
+                                       $this->getOldActorQueryFields( 'ar' ),
+                                       $this->getNewCommentQueryFields( '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' ],
+                                               => [ 'JOIN', 'comment_ar_comment.comment_id = ar_comment_id' ],
                                ],
                        ]
                ];
@@ -240,19 +198,22 @@ class RevisionQueryInfoTest extends MediaWikiTestCase {
                        [
                                'wgContentHandlerUseDB' => false,
                                'wgMultiContentRevisionSchemaMigrationStage' => SCHEMA_COMPAT_OLD,
-                               'wgCommentTableSchemaMigrationStage' => MIGRATION_OLD,
-                               'wgActorTableSchemaMigrationStage' => MIGRATION_OLD,
+                               'wgActorTableSchemaMigrationStage' => SCHEMA_COMPAT_OLD,
                        ],
                        [
                                'tables' => [
                                        'archive',
+                                       'comment_ar_comment' => 'comment',
                                ],
                                'fields' => array_merge(
                                        $this->getArchiveQueryFields( true ),
                                        $this->getOldActorQueryFields( 'ar' ),
-                                       $this->getOldCommentQueryFields( 'ar' )
+                                       $this->getNewCommentQueryFields( 'ar' )
                                ),
-                               'joins' => [],
+                               'joins' => [
+                                       'comment_ar_comment'
+                                               => [ 'JOIN', 'comment_ar_comment.comment_id = ar_comment_id' ],
+                               ],
                        ]
                ];
        }
@@ -263,8 +224,7 @@ class RevisionQueryInfoTest extends MediaWikiTestCase {
                        [
                                'wgContentHandlerUseDB' => true,
                                'wgMultiContentRevisionSchemaMigrationStage' => SCHEMA_COMPAT_NEW,
-                               'wgCommentTableSchemaMigrationStage' => MIGRATION_NEW,
-                               'wgActorTableSchemaMigrationStage' => MIGRATION_NEW,
+                               'wgActorTableSchemaMigrationStage' => SCHEMA_COMPAT_NEW,
                        ],
                        [ 'page', 'user' ],
                        [
@@ -285,7 +245,7 @@ class RevisionQueryInfoTest extends MediaWikiTestCase {
                                        $this->getNewCommentQueryFields( 'rev' )
                                ),
                                'joins' => [
-                                       'page' => [ 'INNER JOIN', [ 'page_id = rev_page' ] ],
+                                       'page' => [ 'JOIN', [ 'page_id = rev_page' ] ],
                                        'user' => [
                                                'LEFT JOIN',
                                                [ 'actor_rev_user.actor_user != 0', 'user_id = actor_rev_user.actor_user' ],
@@ -308,8 +268,7 @@ class RevisionQueryInfoTest extends MediaWikiTestCase {
                                'wgContentHandlerUseDB' => true,
                                '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,22 +285,24 @@ class RevisionQueryInfoTest extends MediaWikiTestCase {
                                        $this->getRevisionQueryFields( false ),
                                        $this->getPageQueryFields(),
                                        $this->getUserQueryFields(),
-                                       $this->getCompatActorQueryFields( 'rev', 'temp_rev_user.revactor_actor' ),
-                                       $this->getCompatCommentQueryFields( 'rev' )
+                                       $this->getNewActorQueryFields( 'rev', 'temp_rev_user.revactor_actor' ),
+                                       $this->getNewCommentQueryFields( 'rev' )
                                ),
                                'joins' => array_merge(
                                        [
-                                               'page' => [ 'INNER JOIN', [ 'page_id = rev_page' ] ],
+                                               'page' => [ 'JOIN', [ 'page_id = rev_page' ] ],
                                                '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',
                                                        ]
                                                ],
+                                               'temp_rev_comment' => [ 'JOIN', 'temp_rev_comment.revcomment_rev = rev_id' ],
+                                               'comment_rev_comment'
+                                                       => [ 'JOIN', 'comment_rev_comment.comment_id = temp_rev_comment.revcomment_comment_id' ],
                                        ],
-                                       $this->getCompatActorJoins( 'rev' ),
-                                       $this->getCompatCommentJoins( 'rev' )
+                                       $this->getNewActorJoins( 'rev' )
                                ),
                        ]
                ];
@@ -350,8 +311,7 @@ class RevisionQueryInfoTest extends MediaWikiTestCase {
                                'wgContentHandlerUseDB' => true,
                                '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,22 +328,24 @@ class RevisionQueryInfoTest extends MediaWikiTestCase {
                                        $this->getRevisionQueryFields( false ),
                                        $this->getPageQueryFields(),
                                        $this->getUserQueryFields(),
-                                       $this->getCompatActorQueryFields( 'rev', 'temp_rev_user.revactor_actor' ),
-                                       $this->getCompatCommentQueryFields( 'rev' )
+                                       $this->getNewActorQueryFields( 'rev', 'temp_rev_user.revactor_actor' ),
+                                       $this->getNewCommentQueryFields( 'rev' )
                                ),
                                'joins' => array_merge(
                                        [
-                                               'page' => [ 'INNER JOIN', [ 'page_id = rev_page' ] ],
+                                               'page' => [ 'JOIN', [ 'page_id = rev_page' ] ],
                                                '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'
                                                        ]
                                                ],
+                                               'temp_rev_comment' => [ 'JOIN', 'temp_rev_comment.revcomment_rev = rev_id' ],
+                                               'comment_rev_comment'
+                                                       => [ 'JOIN', 'comment_rev_comment.comment_id = temp_rev_comment.revcomment_comment_id' ],
                                        ],
-                                       $this->getCompatActorJoins( 'rev' ),
-                                       $this->getCompatCommentJoins( 'rev' )
+                                       $this->getNewActorJoins( 'rev' )
                                ),
                        ]
                ];
@@ -392,28 +354,26 @@ class RevisionQueryInfoTest extends MediaWikiTestCase {
                                'wgContentHandlerUseDB' => true,
                                '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->getCompatCommentQueryFields( 'rev' )
+                                       $this->getOldActorQueryFields( 'rev', 'temp_rev_user.revactor_actor' ),
+                                       $this->getNewCommentQueryFields( 'rev' )
                                ),
-                       'joins' => array_merge(
-                               $this->getCompatActorJoins( 'rev' ),
-                               $this->getCompatCommentJoins( 'rev' )
-                       ),
+                               'joins' => [
+                                       'temp_rev_comment' => [ 'JOIN', 'temp_rev_comment.revcomment_rev = rev_id' ],
+                                       'comment_rev_comment'
+                                               => [ 'JOIN', 'comment_rev_comment.comment_id = temp_rev_comment.revcomment_comment_id' ],
+                               ],
                        ]
                ];
                yield 'MCR write-both/read-old, page, user' => [
@@ -421,8 +381,7 @@ class RevisionQueryInfoTest extends MediaWikiTestCase {
                                'wgContentHandlerUseDB' => true,
                                '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 +389,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,22 +397,23 @@ class RevisionQueryInfoTest extends MediaWikiTestCase {
                                        $this->getContentHandlerQueryFields( 'rev' ),
                                        $this->getUserQueryFields(),
                                        $this->getPageQueryFields(),
-                                       $this->getCompatActorQueryFields( 'rev', 'temp_rev_user.revactor_actor' ),
-                                       $this->getCompatCommentQueryFields( 'rev' )
+                                       $this->getOldActorQueryFields( 'rev', 'temp_rev_user.revactor_actor' ),
+                                       $this->getNewCommentQueryFields( 'rev' )
                                ),
                                'joins' => array_merge(
                                        [
-                                               'page' => [ 'INNER JOIN', [ 'page_id = rev_page' ] ],
+                                               'page' => [ 'JOIN', [ 'page_id = rev_page' ] ],
                                                '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' )
+                                               'temp_rev_comment' => [ 'JOIN', 'temp_rev_comment.revcomment_rev = rev_id' ],
+                                               'comment_rev_comment'
+                                                       => [ 'JOIN', 'comment_rev_comment.comment_id = temp_rev_comment.revcomment_comment_id' ],
+                                       ]
                                ),
                        ]
                ];
@@ -463,42 +421,55 @@ class RevisionQueryInfoTest extends MediaWikiTestCase {
                        [
                                'wgContentHandlerUseDB' => true,
                                'wgMultiContentRevisionSchemaMigrationStage' => SCHEMA_COMPAT_OLD,
-                               'wgCommentTableSchemaMigrationStage' => MIGRATION_OLD,
-                               'wgActorTableSchemaMigrationStage' => MIGRATION_OLD,
+                               'wgActorTableSchemaMigrationStage' => SCHEMA_COMPAT_OLD,
                        ],
                        [],
                        [
-                               'tables' => [ 'revision' ],
+                               'tables' => [
+                                       'revision',
+                                       'temp_rev_comment' => 'revision_comment_temp',
+                                       'comment_rev_comment' => 'comment',
+                               ],
                                'fields' => array_merge(
                                        $this->getRevisionQueryFields( true ),
                                        $this->getContentHandlerQueryFields( 'rev' ),
                                        $this->getOldActorQueryFields( 'rev' ),
-                                       $this->getOldCommentQueryFields( 'rev' )
+                                       $this->getNewCommentQueryFields( 'rev' )
                                ),
-                               'joins' => [],
+                               'joins' => [
+                                       'temp_rev_comment' => [ 'JOIN', 'temp_rev_comment.revcomment_rev = rev_id' ],
+                                       'comment_rev_comment'
+                                               => [ 'JOIN', 'comment_rev_comment.comment_id = temp_rev_comment.revcomment_comment_id' ],
+                               ],
                        ]
                ];
                yield 'pre-MCR, page, user' => [
                        [
                                'wgContentHandlerUseDB' => true,
                                'wgMultiContentRevisionSchemaMigrationStage' => SCHEMA_COMPAT_OLD,
-                               'wgCommentTableSchemaMigrationStage' => MIGRATION_OLD,
-                               'wgActorTableSchemaMigrationStage' => MIGRATION_OLD,
+                               'wgActorTableSchemaMigrationStage' => SCHEMA_COMPAT_OLD,
                        ],
                        [ 'page', 'user' ],
                        [
-                               'tables' => [ 'revision', 'page', 'user' ],
+                               'tables' => [
+                                       'revision', 'page', 'user',
+                                       'temp_rev_comment' => 'revision_comment_temp',
+                                       'comment_rev_comment' => 'comment',
+                               ],
                                'fields' => array_merge(
                                        $this->getRevisionQueryFields( true ),
                                        $this->getContentHandlerQueryFields( 'rev' ),
                                        $this->getPageQueryFields(),
                                        $this->getUserQueryFields(),
                                        $this->getOldActorQueryFields( 'rev' ),
-                                       $this->getOldCommentQueryFields( 'rev' )
+                                       $this->getNewCommentQueryFields( 'rev' )
                                ),
                                'joins' => [
-                                       'page' => [ 'INNER JOIN', [ 'page_id = rev_page' ] ],
+                                       'page' => [ 'JOIN', [ 'page_id = rev_page' ] ],
                                        'user' => [ 'LEFT JOIN', [ 'rev_user != 0', 'user_id = rev_user' ] ],
+                                       'temp_rev_comment' => [ 'JOIN', 'temp_rev_comment.revcomment_rev = rev_id' ],
+                                       'comment_rev_comment'
+                                               => [ 'JOIN', 'comment_rev_comment.comment_id = temp_rev_comment.revcomment_comment_id' ],
                                ],
                        ]
                ];
@@ -506,38 +477,51 @@ class RevisionQueryInfoTest extends MediaWikiTestCase {
                        [
                                'wgContentHandlerUseDB' => false,
                                'wgMultiContentRevisionSchemaMigrationStage' => SCHEMA_COMPAT_OLD,
-                               'wgCommentTableSchemaMigrationStage' => MIGRATION_OLD,
-                               'wgActorTableSchemaMigrationStage' => MIGRATION_OLD,
+                               'wgActorTableSchemaMigrationStage' => SCHEMA_COMPAT_OLD,
                        ],
                        [],
                        [
-                               'tables' => [ 'revision' ],
+                               'tables' => [
+                                       'revision',
+                                       'temp_rev_comment' => 'revision_comment_temp',
+                                       'comment_rev_comment' => 'comment',
+                               ],
                                'fields' => array_merge(
                                        $this->getRevisionQueryFields( true ),
                                        $this->getOldActorQueryFields( 'rev' ),
-                                       $this->getOldCommentQueryFields( 'rev' )
+                                       $this->getNewCommentQueryFields( 'rev' )
                                ),
-                               'joins' => [],
+                               'joins' => [
+                                       'temp_rev_comment' => [ 'JOIN', 'temp_rev_comment.revcomment_rev = rev_id' ],
+                                       'comment_rev_comment'
+                                               => [ 'JOIN', 'comment_rev_comment.comment_id = temp_rev_comment.revcomment_comment_id' ],
+                               ],
                        ],
                ];
                yield 'pre-MCR, no model, page' => [
                        [
                                'wgContentHandlerUseDB' => false,
                                'wgMultiContentRevisionSchemaMigrationStage' => SCHEMA_COMPAT_OLD,
-                               'wgCommentTableSchemaMigrationStage' => MIGRATION_OLD,
-                               'wgActorTableSchemaMigrationStage' => MIGRATION_OLD,
+                               'wgActorTableSchemaMigrationStage' => SCHEMA_COMPAT_OLD,
                        ],
                        [ 'page' ],
                        [
-                               'tables' => [ 'revision', 'page' ],
+                               'tables' => [
+                                       'revision', 'page',
+                                       'temp_rev_comment' => 'revision_comment_temp',
+                                       'comment_rev_comment' => 'comment',
+                               ],
                                'fields' => array_merge(
                                        $this->getRevisionQueryFields( true ),
                                        $this->getPageQueryFields(),
                                        $this->getOldActorQueryFields( 'rev' ),
-                                       $this->getOldCommentQueryFields( 'rev' )
+                                       $this->getNewCommentQueryFields( 'rev' )
                                ),
                                'joins' => [
-                                       'page' => [ 'INNER JOIN', [ 'page_id = rev_page' ], ],
+                                       'page' => [ 'JOIN', [ 'page_id = rev_page' ], ],
+                                       'temp_rev_comment' => [ 'JOIN', 'temp_rev_comment.revcomment_rev = rev_id' ],
+                                       'comment_rev_comment'
+                                               => [ 'JOIN', 'comment_rev_comment.comment_id = temp_rev_comment.revcomment_comment_id' ],
                                ],
                        ],
                ];
@@ -545,20 +529,26 @@ class RevisionQueryInfoTest extends MediaWikiTestCase {
                        [
                                'wgContentHandlerUseDB' => false,
                                'wgMultiContentRevisionSchemaMigrationStage' => SCHEMA_COMPAT_OLD,
-                               'wgCommentTableSchemaMigrationStage' => MIGRATION_OLD,
-                               'wgActorTableSchemaMigrationStage' => MIGRATION_OLD,
+                               'wgActorTableSchemaMigrationStage' => SCHEMA_COMPAT_OLD,
                        ],
                        [ 'user' ],
                        [
-                               'tables' => [ 'revision', 'user' ],
+                               'tables' => [
+                                       'revision', 'user',
+                                       'temp_rev_comment' => 'revision_comment_temp',
+                                       'comment_rev_comment' => 'comment',
+                               ],
                                'fields' => array_merge(
                                        $this->getRevisionQueryFields( true ),
                                        $this->getUserQueryFields(),
                                        $this->getOldActorQueryFields( 'rev' ),
-                                       $this->getOldCommentQueryFields( 'rev' )
+                                       $this->getNewCommentQueryFields( 'rev' )
                                ),
                                'joins' => [
                                        'user' => [ 'LEFT JOIN', [ 'rev_user != 0', 'user_id = rev_user' ] ],
+                                       'temp_rev_comment' => [ 'JOIN', 'temp_rev_comment.revcomment_rev = rev_id' ],
+                                       'comment_rev_comment'
+                                               => [ 'JOIN', 'comment_rev_comment.comment_id = temp_rev_comment.revcomment_comment_id' ],
                                ],
                        ],
                ];
@@ -566,20 +556,26 @@ class RevisionQueryInfoTest extends MediaWikiTestCase {
                        [
                                'wgContentHandlerUseDB' => false,
                                'wgMultiContentRevisionSchemaMigrationStage' => SCHEMA_COMPAT_OLD,
-                               'wgCommentTableSchemaMigrationStage' => MIGRATION_OLD,
-                               'wgActorTableSchemaMigrationStage' => MIGRATION_OLD,
+                               'wgActorTableSchemaMigrationStage' => SCHEMA_COMPAT_OLD,
                        ],
                        [ 'text' ],
                        [
-                               'tables' => [ 'revision', 'text' ],
+                               'tables' => [
+                                       'revision', 'text',
+                                       'temp_rev_comment' => 'revision_comment_temp',
+                                       'comment_rev_comment' => 'comment',
+                               ],
                                'fields' => array_merge(
                                        $this->getRevisionQueryFields( true ),
                                        $this->getTextQueryFields(),
                                        $this->getOldActorQueryFields( 'rev' ),
-                                       $this->getOldCommentQueryFields( 'rev' )
+                                       $this->getNewCommentQueryFields( 'rev' )
                                ),
                                'joins' => [
-                                       'text' => [ 'INNER JOIN', [ 'rev_text_id=old_id' ] ],
+                                       'text' => [ 'JOIN', [ 'rev_text_id=old_id' ] ],
+                                       'temp_rev_comment' => [ 'JOIN', 'temp_rev_comment.revcomment_rev = rev_id' ],
+                                       'comment_rev_comment'
+                                               => [ 'JOIN', 'comment_rev_comment.comment_id = temp_rev_comment.revcomment_comment_id' ],
                                ],
                        ],
                ];
@@ -587,13 +583,14 @@ class RevisionQueryInfoTest extends MediaWikiTestCase {
                        [
                                'wgContentHandlerUseDB' => false,
                                'wgMultiContentRevisionSchemaMigrationStage' => SCHEMA_COMPAT_OLD,
-                               'wgCommentTableSchemaMigrationStage' => MIGRATION_OLD,
-                               'wgActorTableSchemaMigrationStage' => MIGRATION_OLD,
+                               'wgActorTableSchemaMigrationStage' => SCHEMA_COMPAT_OLD,
                        ],
                        [ 'text', 'page', 'user' ],
                        [
                                'tables' => [
-                                       'revision', 'page', 'user', 'text'
+                                       'revision', 'page', 'user', 'text',
+                                       'temp_rev_comment' => 'revision_comment_temp',
+                                       'comment_rev_comment' => 'comment',
                                ],
                                'fields' => array_merge(
                                        $this->getRevisionQueryFields( true ),
@@ -601,11 +598,11 @@ class RevisionQueryInfoTest extends MediaWikiTestCase {
                                        $this->getUserQueryFields(),
                                        $this->getTextQueryFields(),
                                        $this->getOldActorQueryFields( 'rev' ),
-                                       $this->getOldCommentQueryFields( 'rev' )
+                                       $this->getNewCommentQueryFields( 'rev' )
                                ),
                                'joins' => [
                                        'page' => [
-                                               'INNER JOIN',
+                                               'JOIN',
                                                [ 'page_id = rev_page' ],
                                        ],
                                        'user' => [
@@ -616,9 +613,12 @@ class RevisionQueryInfoTest extends MediaWikiTestCase {
                                                ],
                                        ],
                                        'text' => [
-                                               'INNER JOIN',
+                                               'JOIN',
                                                [ 'rev_text_id=old_id' ],
                                        ],
+                                       'temp_rev_comment' => [ 'JOIN', 'temp_rev_comment.revcomment_rev = rev_id' ],
+                                       'comment_rev_comment'
+                                               => [ 'JOIN', 'comment_rev_comment.comment_id = temp_rev_comment.revcomment_comment_id' ],
                                ],
                        ],
                ];
@@ -687,7 +687,7 @@ class RevisionQueryInfoTest extends MediaWikiTestCase {
                                        'content_model',
                                ],
                                'joins' => [
-                                       'content' => [ 'INNER JOIN', [ 'slot_content_id = content_id' ] ],
+                                       'content' => [ 'JOIN', [ 'slot_content_id = content_id' ] ],
                                ],
                        ]
                ];
@@ -715,7 +715,7 @@ class RevisionQueryInfoTest extends MediaWikiTestCase {
                                        'model_name',
                                ],
                                'joins' => [
-                                       'content' => [ 'INNER JOIN', [ 'slot_content_id = content_id' ] ],
+                                       'content' => [ 'JOIN', [ 'slot_content_id = content_id' ] ],
                                        'content_models' => [ 'LEFT JOIN', [ 'content_model = model_id' ] ],
                                ],
                        ]
@@ -731,13 +731,13 @@ class RevisionQueryInfoTest extends MediaWikiTestCase {
                        [],
                        [
                                'tables' => [
-                                       'slots' => 'revision',
+                                       'revision',
                                ],
                                'fields' => array_merge(
                                        [
-                                               'slot_revision_id' => 'slots.rev_id',
+                                               'slot_revision_id' => 'rev_id',
                                                'slot_content_id' => 'NULL',
-                                               'slot_origin' => 'slots.rev_id',
+                                               'slot_origin' => 'rev_id',
                                                'role_name' => $db->addQuotes( SlotRecord::MAIN ),
                                        ]
                                ),
@@ -752,19 +752,20 @@ class RevisionQueryInfoTest extends MediaWikiTestCase {
                        [ 'content' ],
                        [
                                'tables' => [
-                                       'slots' => 'revision',
+                                       'revision',
                                ],
                                'fields' => array_merge(
                                        [
-                                               'slot_revision_id' => 'slots.rev_id',
+                                               'slot_revision_id' => 'rev_id',
                                                'slot_content_id' => 'NULL',
-                                               'slot_origin' => 'slots.rev_id',
+                                               'slot_origin' => 'rev_id',
                                                'role_name' => $db->addQuotes( SlotRecord::MAIN ),
-                                               'content_size' => 'slots.rev_len',
-                                               'content_sha1' => 'slots.rev_sha1',
+                                               'content_size' => 'rev_len',
+                                               'content_sha1' => 'rev_sha1',
                                                'content_address' => $db->buildConcat( [
-                                                       $db->addQuotes( 'tt:' ), 'slots.rev_text_id' ] ),
-                                               'model_name' => 'slots.rev_content_model',
+                                                       $db->addQuotes( 'tt:' ), 'rev_text_id' ] ),
+                                               'rev_text_id' => 'rev_text_id',
+                                               'model_name' => 'rev_content_model',
                                        ]
                                ),
                                'joins' => [],
@@ -778,19 +779,20 @@ class RevisionQueryInfoTest extends MediaWikiTestCase {
                        [ 'content', 'model', 'role' ],
                        [
                                'tables' => [
-                                       'slots' => 'revision',
+                                       'revision',
                                ],
                                'fields' => array_merge(
                                        [
-                                               'slot_revision_id' => 'slots.rev_id',
+                                               'slot_revision_id' => 'rev_id',
                                                'slot_content_id' => 'NULL',
-                                               'slot_origin' => 'slots.rev_id',
+                                               'slot_origin' => 'rev_id',
                                                'role_name' => $db->addQuotes( SlotRecord::MAIN ),
-                                               'content_size' => 'slots.rev_len',
-                                               'content_sha1' => 'slots.rev_sha1',
+                                               'content_size' => 'rev_len',
+                                               'content_sha1' => 'rev_sha1',
                                                'content_address' => $db->buildConcat( [
-                                                       $db->addQuotes( 'tt:' ), 'slots.rev_text_id' ] ),
-                                               'model_name' => 'slots.rev_content_model',
+                                                       $db->addQuotes( 'tt:' ), 'rev_text_id' ] ),
+                                               'rev_text_id' => 'rev_text_id',
+                                               'model_name' => 'rev_content_model',
                                        ]
                                ),
                                'joins' => [],
@@ -804,13 +806,13 @@ class RevisionQueryInfoTest extends MediaWikiTestCase {
                        [],
                        [
                                'tables' => [
-                                       'slots' => 'revision',
+                                       'revision',
                                ],
                                'fields' => array_merge(
                                        [
-                                               'slot_revision_id' => 'slots.rev_id',
+                                               'slot_revision_id' => 'rev_id',
                                                'slot_content_id' => 'NULL',
-                                               'slot_origin' => 'slots.rev_id',
+                                               'slot_origin' => 'rev_id',
                                                'role_name' => $db->addQuotes( SlotRecord::MAIN ),
                                        ]
                                ),
@@ -825,19 +827,20 @@ class RevisionQueryInfoTest extends MediaWikiTestCase {
                        [ 'content' ],
                        [
                                'tables' => [
-                                       'slots' => 'revision',
+                                       'revision',
                                ],
                                'fields' => array_merge(
                                        [
-                                               'slot_revision_id' => 'slots.rev_id',
+                                               'slot_revision_id' => 'rev_id',
                                                'slot_content_id' => 'NULL',
-                                               'slot_origin' => 'slots.rev_id',
+                                               'slot_origin' => 'rev_id',
                                                'role_name' => $db->addQuotes( SlotRecord::MAIN ),
-                                               'content_size' => 'slots.rev_len',
-                                               'content_sha1' => 'slots.rev_sha1',
+                                               'content_size' => 'rev_len',
+                                               'content_sha1' => 'rev_sha1',
                                                'content_address' =>
-                                                       $db->buildConcat( [ $db->addQuotes( 'tt:' ), 'slots.rev_text_id' ] ),
-                                               'model_name' => 'slots.rev_content_model',
+                                                       $db->buildConcat( [ $db->addQuotes( 'tt:' ), 'rev_text_id' ] ),
+                                               'rev_text_id' => 'rev_text_id',
+                                               'model_name' => 'rev_content_model',
                                        ]
                                ),
                                'joins' => [],
@@ -849,8 +852,7 @@ class RevisionQueryInfoTest extends MediaWikiTestCase {
                yield 'with model, comment, and actor' => [
                        [
                                'wgContentHandlerUseDB' => true,
-                               'wgCommentTableSchemaMigrationStage' => MIGRATION_WRITE_BOTH,
-                               'wgActorTableSchemaMigrationStage' => MIGRATION_WRITE_BOTH,
+                               'wgActorTableSchemaMigrationStage' => SCHEMA_COMPAT_WRITE_BOTH | SCHEMA_COMPAT_READ_OLD,
                        ],
                        'fields' => array_merge(
                                [
@@ -869,7 +871,6 @@ class RevisionQueryInfoTest extends MediaWikiTestCase {
                                ],
                                $this->getContentHandlerQueryFields( 'rev' ),
                                [
-                                       'rev_comment_old' => 'rev_comment',
                                        'rev_comment_pk' => 'rev_id',
                                ]
                        ),
@@ -877,8 +878,7 @@ class RevisionQueryInfoTest extends MediaWikiTestCase {
                yield 'no mode, no comment, no actor' => [
                        [
                                'wgContentHandlerUseDB' => false,
-                               'wgCommentTableSchemaMigrationStage' => MIGRATION_OLD,
-                               'wgActorTableSchemaMigrationStage' => MIGRATION_OLD,
+                               'wgActorTableSchemaMigrationStage' => SCHEMA_COMPAT_OLD,
                        ],
                        'fields' => array_merge(
                                [
@@ -894,8 +894,8 @@ class RevisionQueryInfoTest extends MediaWikiTestCase {
                                        'rev_len',
                                        'rev_parent_id',
                                        'rev_sha1',
-                               ],
-                               $this->getOldCommentQueryFields( 'rev' )
+                                       'rev_comment_pk' => 'rev_id',
+                               ]
                        ),
                ];
        }
@@ -904,8 +904,7 @@ class RevisionQueryInfoTest extends MediaWikiTestCase {
                yield 'with model, comment, and actor' => [
                        [
                                'wgContentHandlerUseDB' => true,
-                               'wgCommentTableSchemaMigrationStage' => MIGRATION_WRITE_BOTH,
-                               'wgActorTableSchemaMigrationStage' => MIGRATION_WRITE_BOTH,
+                               'wgActorTableSchemaMigrationStage' => SCHEMA_COMPAT_WRITE_BOTH | SCHEMA_COMPAT_READ_OLD,
                        ],
                        'fields' => array_merge(
                                [
@@ -925,7 +924,6 @@ class RevisionQueryInfoTest extends MediaWikiTestCase {
                                ],
                                $this->getContentHandlerQueryFields( 'ar' ),
                                [
-                                       'ar_comment_old' => 'ar_comment',
                                        'ar_comment_id' => 'ar_comment_id',
                                ]
                        ),
@@ -933,8 +931,7 @@ class RevisionQueryInfoTest extends MediaWikiTestCase {
                yield 'no mode, no comment, no actor' => [
                        [
                                'wgContentHandlerUseDB' => false,
-                               'wgCommentTableSchemaMigrationStage' => MIGRATION_OLD,
-                               'wgActorTableSchemaMigrationStage' => MIGRATION_OLD,
+                               'wgActorTableSchemaMigrationStage' => SCHEMA_COMPAT_OLD,
                        ],
                        'fields' => array_merge(
                                [
@@ -951,8 +948,8 @@ class RevisionQueryInfoTest extends MediaWikiTestCase {
                                        'ar_len',
                                        'ar_parent_id',
                                        'ar_sha1',
-                               ],
-                               $this->getOldCommentQueryFields( 'ar' )
+                                       'ar_comment_id' => 'ar_comment_id',
+                               ]
                        ),
                ];
        }
@@ -986,7 +983,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' ] ],
@@ -1000,7 +997,7 @@ class RevisionQueryInfoTest extends MediaWikiTestCase {
        public function testRevisionPageJoinCond() {
                $this->hideDeprecated( 'Revision::pageJoinCond' );
                $this->assertEquals(
-                       [ 'INNER JOIN', [ 'page_id = rev_page' ] ],
+                       [ 'JOIN', [ 'page_id = rev_page' ] ],
                        Revision::pageJoinCond()
                );
        }