From b6dfaa50ad317aa8da0446431ddd6bc5afec9c12 Mon Sep 17 00:00:00 2001 From: Petr Pchelko Date: Thu, 19 Sep 2019 10:53:19 -0700 Subject: [PATCH] Remove Revision::getRevisionText from migrateArchiveText The script is used to migrate archive text from pre-1.5 schema. It's safe it just use the `ar_text` field directly instead of going to Revision::getRevisionText since migrating this field is the whole proing of the script. Per execution it checks that the field exists in the schema, the SQL query reads the field. We don't need to do `expandBlob` either, cause we already know that the data is not in external store, thus Revision::decompressData is enough. Bug: T198343 Change-Id: Ic838bdf680d73522dd508dd86056eb945535b368 --- maintenance/migrateArchiveText.php | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/maintenance/migrateArchiveText.php b/maintenance/migrateArchiveText.php index 2271c393a8..7bbf3d0905 100644 --- a/maintenance/migrateArchiveText.php +++ b/maintenance/migrateArchiveText.php @@ -21,6 +21,8 @@ * @ingroup Maintenance */ +use MediaWiki\MediaWikiServices; + require_once __DIR__ . '/Maintenance.php'; /** @@ -57,6 +59,10 @@ class MigrateArchiveText extends LoggedUpdateMaintenance { protected function doDBUpdates() { $replaceMissing = $this->hasOption( 'replace-missing' ); $defaultExternalStore = $this->getConfig()->get( 'DefaultExternalStore' ); + // @phan-suppress-next-line PhanAccessMethodInternal + $blobStore = MediaWikiServices::getInstance() + ->getBlobStoreFactory() + ->newSqlBlobStore(); $batchSize = $this->getBatchSize(); $dbr = $this->getDB( DB_REPLICA, [ 'vslow' ] ); @@ -90,8 +96,9 @@ class MigrateArchiveText extends LoggedUpdateMaintenance { // Recompress the text (and store in external storage, if // applicable) if it's not already in external storage. - if ( !in_array( 'external', explode( ',', $row->ar_flags ), true ) ) { - $data = Revision::getRevisionText( $row, 'ar_' ); + $arFlags = explode( ',', $row->ar_flags ); + if ( !in_array( 'external', $arFlags, true ) ) { + $data = $blobStore->decompressData( $row->ar_text, $arFlags ); if ( $data !== false ) { $flags = Revision::compressRevisionText( $data ); -- 2.20.1