- $res = $dbr->select( 'revision', [ 'rev_id', 'rev_text_id' ],
- [ "rev_id BETWEEN $chunkStart AND $chunkEnd" ], __METHOD__ );
- foreach ( $res as $row ) {
- $this->oldIdMap[$row->rev_id] = $row->rev_text_id;
+
+ // Fetch revision rows
+ if ( $wgMultiContentRevisionSchemaMigrationStage & SCHEMA_COMPAT_READ_OLD ) {
+ $res = $dbr->select( 'revision', [ 'rev_id', 'rev_text_id' ],
+ [ "rev_id BETWEEN $chunkStart AND $chunkEnd" ], __METHOD__ );
+ foreach ( $res as $row ) {
+ if ( !isset( $this->oldIdMap[ $row->rev_text_id ] ) ) {
+ $this->oldIdMap[ $row->rev_text_id ] = [ $row->rev_id ];
+ } elseif ( !in_array( $row->rev_id, $this->oldIdMap[ $row->rev_text_id ] ) ) {
+ $this->oldIdMap[ $row->rev_text_id ][] = $row->rev_id;
+ }
+ }
+ } else {
+ $res = $dbr->select(
+ [ 'slots', 'content' ],
+ [ 'slot_revision_id', 'content_address' ],
+ [ "slot_revision_id BETWEEN $chunkStart AND $chunkEnd" ],
+ __METHOD__,
+ [],
+ [ 'content' => [ 'INNER JOIN', [ 'content_id = slot_content_id' ] ] ]
+ );
+ $blobStore = MediaWikiServices::getInstance()->getBlobStore();
+ foreach ( $res as $row ) {
+ $textId = $blobStore->getTextIdFromAddress( $row->content_address );
+ if ( $textId ) {
+ if ( !isset( $this->oldIdMap[$textId] ) ) {
+ $this->oldIdMap[ $textId ] = [ $row->slot_revision_id ];
+ } elseif ( !in_array( $row->slot_revision_id, $this->oldIdMap[$textId] ) ) {
+ $this->oldIdMap[ $textId ][] = $row->slot_revision_id;
+ }
+ }
+ }