+ $fields = [ 'rev_id', 'rev_page', 'old_id', 'old_flags', 'old_text' ];
+ $options = [
+ 'ORDER BY' => 'rev_id',
+ 'LIMIT' => $this->batchSize
+ ];
+ $conds = [
+ $textClause,
+ 'old_flags ' . $dbr->buildLike( $dbr->anyString(), 'external', $dbr->anyString() ),
+ ];
+ if ( $wgMultiContentRevisionSchemaMigrationStage & SCHEMA_COMPAT_READ_OLD ) {
+ $tables = [ 'revision', 'text' ];
+ $conds = array_merge( [
+ 'rev_text_id=old_id',
+ ], $conds );
+ } else {
+ $slotRoleStore = MediaWikiServices::getInstance()->getSlotRoleStore();
+ $tables = [ 'revision', 'slots', 'content', 'text' ];
+ $conds = array_merge( [
+ 'rev_id=slot_revision_id',
+ 'slot_role_id=' . $slotRoleStore->getId( SlotRecord::MAIN ),
+ 'content_id=slot_content_id',
+ 'SUBSTRING(content_address, 1, 3)=' . $dbr->addQuotes( 'tt:' ),
+ 'SUBSTRING(content_address, 4)=old_id',
+ ], $conds );
+ }
+