for two-stage dumps make the location of MWScript.php alterable
authorAriel T. Glenn <ariel@wikimedia.org>
Thu, 20 Sep 2018 14:55:58 +0000 (17:55 +0300)
committerAriel T. Glenn <ariel@wikimedia.org>
Thu, 16 May 2019 07:44:43 +0000 (10:44 +0300)
Previously it was fixed to be in a certain location relative to
the MW instllation; this would allow the path to the script to
be passed in as an argument. If not, the script reverts to its
previous behavior.

Bug: T204962
Change-Id: Ib9fcf073332670149544d56e375541d014600371

maintenance/includes/TextPassDumper.php

index 03cad5c..eaed7ed 100644 (file)
@@ -133,7 +133,8 @@ TEXT
                $this->addOption( 'quiet', 'Don\'t dump status reports to stderr.' );
                $this->addOption( 'full', 'Dump all revisions of every page' );
                $this->addOption( 'current', 'Base ETA on number of pages in database instead of all revisions' );
-               $this->addOption( 'spawn', 'Spawn a subprocess for loading text records' );
+               $this->addOption( 'spawn', 'Spawn a subprocess for loading text records, optionally specify ' .
+                       'php[,mwscript] paths' );
                $this->addOption( 'buffersize', 'Buffer size in bytes to use for reading the stub. ' .
                        '(Default: 512KB, Minimum: 4KB)', false, true );
 
@@ -191,7 +192,7 @@ TEXT
                        $this->spawn = true;
                        $val = $this->getOption( 'spawn' );
                        if ( $val !== 1 ) {
-                               $this->php = $val;
+                               $this->php = explode( ',', $val, 2 );
                        }
                }
        }
@@ -756,19 +757,24 @@ TEXT
        function openSpawn() {
                global $IP;
 
-               if ( file_exists( "$IP/../multiversion/MWScript.php" ) ) {
+               if ( count( $this->php ) == 2 ) {
+                       $mwscriptpath = $this->php[1];
+               } else {
+                       $mwscriptpath = "$IP/../multiversion/MWScript.php";
+               }
+               if ( file_exists( $mwscriptpath ) ) {
                        $cmd = implode( " ",
                                array_map( [ Shell::class, 'escape' ],
                                        [
-                                               $this->php,
-                                               "$IP/../multiversion/MWScript.php",
+                                               $this->php[0],
+                                               $mwscriptpath,
                                                "fetchText.php",
                                                '--wiki', wfWikiID() ] ) );
                } else {
                        $cmd = implode( " ",
                                array_map( [ Shell::class, 'escape' ],
                                        [
-                                               $this->php,
+                                               $this->php[0],
                                                "$IP/maintenance/fetchText.php",
                                                '--wiki', wfWikiID() ] ) );
                }