Fix double dot in filename
[lhc/web/wiklou.git] / maintenance / storage / compressOld.php
index d3e9ce2..c4779b9 100644 (file)
@@ -188,7 +188,9 @@ class CompressOld extends Maintenance {
 
                # Store in external storage if required
                if ( $extdb !== '' ) {
-                       $storeObj = new ExternalStoreDB;
+                       $esFactory = MediaWikiServices::getInstance()->getExternalStoreFactory();
+                       /** @var ExternalStoreDB $storeObj */
+                       $storeObj = $esFactory->getStore( 'DB' );
                        $compress = $storeObj->store( $extdb, $compress );
                        if ( $compress === false ) {
                                $this->error( "Unable to store object" );
@@ -221,6 +223,7 @@ class CompressOld extends Maintenance {
         * @param string $extdb
         * @param bool|int $maxPageId
         * @return bool
+        * @suppress PhanTypeInvalidDimOffset
         */
        private function compressWithConcat( $startId, $maxChunkSize, $beginDate,
                $endDate, $extdb = "", $maxPageId = false
@@ -232,8 +235,14 @@ class CompressOld extends Maintenance {
 
                # Set up external storage
                if ( $extdb != '' ) {
-                       $storeObj = new ExternalStoreDB;
+                       $esFactory = MediaWikiServices::getInstance()->getExternalStoreFactory();
+                       /** @var ExternalStoreDB $storeObj */
+                       $storeObj = $esFactory->getStore( 'DB' );
                }
+               // @phan-suppress-next-line PhanAccessMethodInternal
+               $blobStore = MediaWikiServices::getInstance()
+                       ->getBlobStoreFactory()
+                       ->newSqlBlobStore();
 
                # Get all articles by page_id
                if ( !$maxPageId ) {
@@ -365,8 +374,12 @@ class CompressOld extends Maintenance {
                                for ( $j = 0; $j < $thisChunkSize && $chunk->isHappy(); $j++ ) {
                                        $oldid = $revs[$i + $j]->old_id;
 
-                                       # Get text
-                                       $text = Revision::getRevisionText( $revs[$i + $j] );
+                                       # Get text. We do not need the full `extractBlob` since the query is built
+                                       # to fetch non-externalstore blobs.
+                                       $text = $blobStore->decompressData(
+                                               $revs[$i + $j]->old_text,
+                                               explode( ',', $revs[$i + $j]->old_flags )
+                                       );
 
                                        if ( $text === false ) {
                                                $this->error( "\nError, unable to get text in old_id $oldid" );