Add ability to override mb_strtoupper in Language::ucfirst
[lhc/web/wiklou.git] / maintenance / dumpTextPass.php
index 0479a91..7566fe0 100644 (file)
@@ -29,8 +29,8 @@ require_once __DIR__ . '/7zip.inc';
 require_once __DIR__ . '/../includes/export/WikiExporter.php';
 
 use MediaWiki\MediaWikiServices;
+use MediaWiki\Shell\Shell;
 use MediaWiki\Storage\BlobAccessException;
-use MediaWiki\Storage\BlobStore;
 use MediaWiki\Storage\SqlBlobStore;
 use Wikimedia\Rdbms\IMaintainableDatabase;
 
@@ -143,7 +143,7 @@ TEXT
        }
 
        /**
-        * @return BlobStore
+        * @return SqlBlobStore
         */
        private function getBlobStore() {
                return MediaWikiServices::getInstance()->getBlobStore();
@@ -737,16 +737,16 @@ TEXT
        }
 
        /**
-        * @param int|string $id Content address, or text row ID.
+        * @param int|string $address Content address, or text row ID.
         * @return bool|string
         */
-       private function getTextSpawned( $id ) {
+       private function getTextSpawned( $address ) {
                Wikimedia\suppressWarnings();
                if ( !$this->spawnProc ) {
                        // First time?
                        $this->openSpawn();
                }
-               $text = $this->getTextSpawnedOnce( $id );
+               $text = $this->getTextSpawnedOnce( $address );
                Wikimedia\restoreWarnings();
 
                return $text;
@@ -757,7 +757,7 @@ TEXT
 
                if ( file_exists( "$IP/../multiversion/MWScript.php" ) ) {
                        $cmd = implode( " ",
-                               array_map( 'wfEscapeShellArg',
+                               array_map( [ Shell::class, 'escape' ],
                                        [
                                                $this->php,
                                                "$IP/../multiversion/MWScript.php",
@@ -765,7 +765,7 @@ TEXT
                                                '--wiki', wfWikiID() ] ) );
                } else {
                        $cmd = implode( " ",
-                               array_map( 'wfEscapeShellArg',
+                               array_map( [ Shell::class, 'escape' ],
                                        [
                                                $this->php,
                                                "$IP/maintenance/fetchText.php",
@@ -814,11 +814,15 @@ TEXT
        }
 
        /**
-        * @param int|string $id Content address, or text row ID.
+        * @param int|string $address Content address, or text row ID.
         * @return bool|string
         */
-       private function getTextSpawnedOnce( $id ) {
-               $ok = fwrite( $this->spawnWrite, "$id\n" );
+       private function getTextSpawnedOnce( $address ) {
+               if ( is_int( $address ) || intval( $address ) ) {
+                       $address = SqlBlobStore::makeAddressFromTextId( (int)$address );
+               }
+
+               $ok = fwrite( $this->spawnWrite, "$address\n" );
                // $this->progress( ">> $id" );
                if ( !$ok ) {
                        return false;
@@ -830,26 +834,18 @@ TEXT
                        return false;
                }
 
-               // check that the text id they are sending is the one we asked for
+               // check that the text address they are sending is the one we asked for
                // this avoids out of sync revision text errors we have encountered in the past
                $newAddress = fgets( $this->spawnRead );
                if ( $newAddress === false ) {
                        return false;
                }
+               $newAddress = trim( $newAddress );
                if ( strpos( $newAddress, ':' ) === false ) {
-                       $newId = intval( $newAddress );
-                       if ( $newId === false ) {
-                               return false;
-                       }
-               } else {
-                       try {
-                               $newAddressFields = SqlBlobStore::splitBlobAddress( $newAddress );
-                               $newId = $newAddressFields[ 1 ];
-                       } catch ( InvalidArgumentException $ex ) {
-                               return false;
-                       }
+                       $newAddress = SqlBlobStore::makeAddressFromTextId( intval( $newAddress ) );
                }
-               if ( $id != intval( $newId ) ) {
+
+               if ( $newAddress !== $address ) {
                        return false;
                }