diff options
author | Bill Pirkle <bpirkle@wikimedia.org> | 2019-03-15 10:59:41 -0500 |
---|---|---|
committer | Bill Pirkle <bpirkle@wikimedia.org> | 2019-03-19 10:50:54 -0500 |
commit | f7afe42713a53452ac808ea337eb8390414b47eb (patch) | |
tree | a0eafb016f387436c74f5f0efd845c2eb00df628 /maintenance/Maintenance.php | |
parent | c7d3fcebc435e35389c0ae49bb37d7199e329ac1 (diff) | |
download | mediawikicore-f7afe42713a53452ac808ea337eb8390414b47eb.tar.gz mediawikicore-f7afe42713a53452ac808ea337eb8390414b47eb.zip |
Remove many references to db fields being retired as part of MCR Schema Migration
Remove many references to database fields rev_text_id and ar_text_id,
which are being retired as part of MCR Schema Migration.
Some references remain, and will be removed under other patchsets
or other tasks.
Bug: T198341
Change-Id: Id044b8dcd7c9d09d5d6037eb732f6a105933f516
Diffstat (limited to 'maintenance/Maintenance.php')
-rw-r--r-- | maintenance/Maintenance.php | 48 |
1 files changed, 33 insertions, 15 deletions
diff --git a/maintenance/Maintenance.php b/maintenance/Maintenance.php index b638b42dff56..ad748f330ad4 100644 --- a/maintenance/Maintenance.php +++ b/maintenance/Maintenance.php @@ -1281,27 +1281,45 @@ abstract class Maintenance { * @author Rob Church <robchur@gmail.com> */ public function purgeRedundantText( $delete = true ) { + global $wgMultiContentRevisionSchemaMigrationStage; + # Data should come off the master, wrapped in a transaction $dbw = $this->getDB( DB_MASTER ); $this->beginTransaction( $dbw, __METHOD__ ); - # Get "active" text records from the revisions table - $cur = []; - $this->output( 'Searching for active text records in revisions table...' ); - $res = $dbw->select( 'revision', 'rev_text_id', [], __METHOD__, [ 'DISTINCT' ] ); - foreach ( $res as $row ) { - $cur[] = $row->rev_text_id; - } - $this->output( "done.\n" ); + if ( $wgMultiContentRevisionSchemaMigrationStage & SCHEMA_COMPAT_READ_OLD ) { + # Get "active" text records from the revisions table + $cur = []; + $this->output( 'Searching for active text records in revisions table...' ); + $res = $dbw->select( 'revision', 'rev_text_id', [], __METHOD__, [ 'DISTINCT' ] ); + foreach ( $res as $row ) { + $cur[] = $row->rev_text_id; + } + $this->output( "done.\n" ); - # Get "active" text records from the archive table - $this->output( 'Searching for active text records in archive table...' ); - $res = $dbw->select( 'archive', 'ar_text_id', [], __METHOD__, [ 'DISTINCT' ] ); - foreach ( $res as $row ) { - # old pre-MW 1.5 records can have null ar_text_id's. - if ( $row->ar_text_id !== null ) { - $cur[] = $row->ar_text_id; + # Get "active" text records from the archive table + $this->output( 'Searching for active text records in archive table...' ); + $res = $dbw->select( 'archive', 'ar_text_id', [], __METHOD__, [ 'DISTINCT' ] ); + foreach ( $res as $row ) { + # old pre-MW 1.5 records can have null ar_text_id's. + if ( $row->ar_text_id !== null ) { + $cur[] = $row->ar_text_id; + } + } + $this->output( "done.\n" ); + } else { + # Get "active" text records via the content table + $cur = []; + $this->output( 'Searching for active text records via contents table...' ); + $res = $dbw->select( 'content', 'content_address', [], __METHOD__, [ 'DISTINCT' ] ); + $blobStore = MediaWikiServices::getInstance()->getBlobStore(); + foreach ( $res as $row ) { + $textId = $blobStore->getTextIdFromAddress( $row->content_address ); + if ( $textId ) { + $cur[] = $textId; + } } + $this->output( "done.\n" ); } $this->output( "done.\n" ); |