X-Git-Url: https://git.cyclocoop.org/admin/?a=blobdiff_plain;f=maintenance%2FMaintenance.php;h=ad748f330ad467d448afe9321a42161e354ecb62;hb=23b5c0891a0d89b3f0e5963f0e992ab4a1eebf5d;hp=e76426d01a690c0b92064abf51a78c961ca39d98;hpb=e143d720c5c1e98ba8b15af2c0dac0de34b87594;p=lhc%2Fweb%2Fwiklou.git diff --git a/maintenance/Maintenance.php b/maintenance/Maintenance.php index e76426d01a..ad748f330a 100644 --- a/maintenance/Maintenance.php +++ b/maintenance/Maintenance.php @@ -1251,7 +1251,7 @@ abstract class Maintenance { $settingsFile = "$IP/LocalSettings.php"; } if ( isset( $this->mOptions['wiki'] ) ) { - $bits = explode( '-', $this->mOptions['wiki'] ); + $bits = explode( '-', $this->mOptions['wiki'], 2 ); if ( count( $bits ) == 1 ) { $bits[] = ''; } @@ -1281,27 +1281,45 @@ abstract class Maintenance { * @author Rob Church */ 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" ); @@ -1326,7 +1344,6 @@ abstract class Maintenance { $this->output( "done.\n" ); } - # Done $this->commitTransaction( $dbw, __METHOD__ ); } @@ -1349,11 +1366,10 @@ abstract class Maintenance { * @return IMaintainableDatabase */ protected function getDB( $db, $groups = [], $wiki = false ) { - if ( is_null( $this->mDb ) ) { + if ( $this->mDb === null ) { return wfGetDB( $db, $groups, $wiki ); - } else { - return $this->mDb; } + return $this->mDb; } /**