jenkins-bot has submitted this change and it was merged. ( 
https://gerrit.wikimedia.org/r/336948 )

Change subject: Update symfony/process to 3.0.9
......................................................................


Update symfony/process to 3.0.9

https://github.com/symfony/process/compare/v3.0.4...v3.0.9

Change-Id: I77d538c755d5bdce668fcf6584167ffa1ed79ecd
---
M composer.json
M composer.lock
M composer/installed.json
M symfony/process/Pipes/AbstractPipes.php
M symfony/process/Pipes/PipesInterface.php
M symfony/process/Pipes/WindowsPipes.php
M symfony/process/Process.php
M symfony/process/ProcessBuilder.php
M symfony/process/ProcessUtils.php
M symfony/process/Tests/ProcessTest.php
10 files changed, 139 insertions(+), 95 deletions(-)

Approvals:
  BryanDavis: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/composer.json b/composer.json
index 8270bb0..2c9cdef 100644
--- a/composer.json
+++ b/composer.json
@@ -33,7 +33,7 @@
                "psr/log": "1.0.2",
                "ruflin/elastica": "3.1.1",
                "stil/gd-text":  "1.0.0",
-               "symfony/process": "3.0.4",
+               "symfony/process": "3.0.9",
                "wikimedia/assert": "0.2.2",
                "wikimedia/avro": "1.7.7",
                "wikimedia/base-convert": "1.0.1",
diff --git a/composer.lock b/composer.lock
index 7e740d6..5505ce7 100644
--- a/composer.lock
+++ b/composer.lock
@@ -4,8 +4,8 @@
         "Read more about it at 
https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file";,
         "This file is @generated automatically"
     ],
-    "hash": "f0fa1222397a98ccd124dcf0d66a7144",
-    "content-hash": "29352279c5eae2b74f1c7a5ec6420277",
+    "hash": "2ec039fb2c33cd0bc24ff57aa09f68ce",
+    "content-hash": "429b368590d31d91ac00a6fcd1d899e0",
     "packages": [
         {
             "name": "composer/semver",
@@ -1199,16 +1199,16 @@
         },
         {
             "name": "symfony/process",
-            "version": "v3.0.4",
+            "version": "v3.0.9",
             "source": {
                 "type": "git",
                 "url": "https://github.com/symfony/process.git";,
-                "reference": "e6f1f98bbd355d209a992bfff45e7edfbd4a0776"
+                "reference": "768debc5996f599c4372b322d9061dba2a4bf505"
             },
             "dist": {
                 "type": "zip",
-                "url": 
"https://api.github.com/repos/symfony/process/zipball/e6f1f98bbd355d209a992bfff45e7edfbd4a0776";,
-                "reference": "e6f1f98bbd355d209a992bfff45e7edfbd4a0776",
+                "url": 
"https://api.github.com/repos/symfony/process/zipball/768debc5996f599c4372b322d9061dba2a4bf505";,
+                "reference": "768debc5996f599c4372b322d9061dba2a4bf505",
                 "shasum": ""
             },
             "require": {
@@ -1244,7 +1244,7 @@
             ],
             "description": "Symfony Process Component",
             "homepage": "https://symfony.com";,
-            "time": "2016-03-30 10:41:14"
+            "time": "2016-07-28 11:13:34"
         },
         {
             "name": "wikimedia/assert",
diff --git a/composer/installed.json b/composer/installed.json
index 2ca67f2..989b3de 100644
--- a/composer/installed.json
+++ b/composer/installed.json
@@ -972,57 +972,6 @@
         "homepage": "http://pear.php.net/package/Mail";
     },
     {
-        "name": "symfony/process",
-        "version": "v3.0.4",
-        "version_normalized": "3.0.4.0",
-        "source": {
-            "type": "git",
-            "url": "https://github.com/symfony/process.git";,
-            "reference": "e6f1f98bbd355d209a992bfff45e7edfbd4a0776"
-        },
-        "dist": {
-            "type": "zip",
-            "url": 
"https://api.github.com/repos/symfony/process/zipball/e6f1f98bbd355d209a992bfff45e7edfbd4a0776";,
-            "reference": "e6f1f98bbd355d209a992bfff45e7edfbd4a0776",
-            "shasum": ""
-        },
-        "require": {
-            "php": ">=5.5.9"
-        },
-        "time": "2016-03-30 10:41:14",
-        "type": "library",
-        "extra": {
-            "branch-alias": {
-                "dev-master": "3.0-dev"
-            }
-        },
-        "installation-source": "dist",
-        "autoload": {
-            "psr-4": {
-                "Symfony\\Component\\Process\\": ""
-            },
-            "exclude-from-classmap": [
-                "/Tests/"
-            ]
-        },
-        "notification-url": "https://packagist.org/downloads/";,
-        "license": [
-            "MIT"
-        ],
-        "authors": [
-            {
-                "name": "Fabien Potencier",
-                "email": "[email protected]"
-            },
-            {
-                "name": "Symfony Community",
-                "homepage": "https://symfony.com/contributors";
-            }
-        ],
-        "description": "Symfony Process Component",
-        "homepage": "https://symfony.com";
-    },
-    {
         "name": "monolog/monolog",
         "version": "1.18.2",
         "version_normalized": "1.18.2.0",
@@ -2098,5 +2047,56 @@
             "container",
             "dependency injection"
         ]
+    },
+    {
+        "name": "symfony/process",
+        "version": "v3.0.9",
+        "version_normalized": "3.0.9.0",
+        "source": {
+            "type": "git",
+            "url": "https://github.com/symfony/process.git";,
+            "reference": "768debc5996f599c4372b322d9061dba2a4bf505"
+        },
+        "dist": {
+            "type": "zip",
+            "url": 
"https://api.github.com/repos/symfony/process/zipball/768debc5996f599c4372b322d9061dba2a4bf505";,
+            "reference": "768debc5996f599c4372b322d9061dba2a4bf505",
+            "shasum": ""
+        },
+        "require": {
+            "php": ">=5.5.9"
+        },
+        "time": "2016-07-28 11:13:34",
+        "type": "library",
+        "extra": {
+            "branch-alias": {
+                "dev-master": "3.0-dev"
+            }
+        },
+        "installation-source": "dist",
+        "autoload": {
+            "psr-4": {
+                "Symfony\\Component\\Process\\": ""
+            },
+            "exclude-from-classmap": [
+                "/Tests/"
+            ]
+        },
+        "notification-url": "https://packagist.org/downloads/";,
+        "license": [
+            "MIT"
+        ],
+        "authors": [
+            {
+                "name": "Fabien Potencier",
+                "email": "[email protected]"
+            },
+            {
+                "name": "Symfony Community",
+                "homepage": "https://symfony.com/contributors";
+            }
+        ],
+        "description": "Symfony Process Component",
+        "homepage": "https://symfony.com";
     }
 ]
diff --git a/symfony/process/Pipes/AbstractPipes.php 
b/symfony/process/Pipes/AbstractPipes.php
index f2fd35e..ffa6a88 100644
--- a/symfony/process/Pipes/AbstractPipes.php
+++ b/symfony/process/Pipes/AbstractPipes.php
@@ -22,10 +22,9 @@
     public $pipes = array();
 
     /** @var string */
-    protected $inputBuffer = '';
+    private $inputBuffer = '';
     /** @var resource|null */
-    protected $input;
-
+    private $input;
     /** @var bool */
     private $blocked = true;
 
@@ -91,9 +90,8 @@
         if (!isset($this->pipes[0])) {
             return;
         }
-
-        $e = array();
-        $r = null !== $this->input ? array($this->input) : $e;
+        $input = $this->input;
+        $r = $e = array();
         $w = array($this->pipes[0]);
 
         // let's have a look if something changed in streams
@@ -110,7 +108,7 @@
                 }
             }
 
-            foreach ($r as $input) {
+            if ($input) {
                 for (;;) {
                     $data = fread($input, self::CHUNK_SIZE);
                     if (!isset($data[0])) {
@@ -124,7 +122,7 @@
                         return array($this->pipes[0]);
                     }
                 }
-                if (!isset($data[0]) && feof($input)) {
+                if (feof($input)) {
                     // no more data to read on input resource
                     // use an empty buffer in the next reads
                     $this->input = null;
diff --git a/symfony/process/Pipes/PipesInterface.php 
b/symfony/process/Pipes/PipesInterface.php
index 09d3f61..b91c393 100644
--- a/symfony/process/Pipes/PipesInterface.php
+++ b/symfony/process/Pipes/PipesInterface.php
@@ -39,10 +39,10 @@
     /**
      * Reads data in file handles and pipes.
      *
-     * @param bool $blocking Whether to use blocking calls or not.
-     * @param bool $close    Whether to close pipes if they've reached EOF.
+     * @param bool $blocking Whether to use blocking calls or not
+     * @param bool $close    Whether to close pipes if they've reached EOF
      *
-     * @return string[] An array of read data indexed by their fd.
+     * @return string[] An array of read data indexed by their fd
      */
     public function readAndWrite($blocking, $close = false);
 
diff --git a/symfony/process/Pipes/WindowsPipes.php 
b/symfony/process/Pipes/WindowsPipes.php
index 23e412c..db66c67 100644
--- a/symfony/process/Pipes/WindowsPipes.php
+++ b/symfony/process/Pipes/WindowsPipes.php
@@ -47,15 +47,35 @@
             // Workaround for this problem is to use temporary files instead 
of pipes on Windows platform.
             //
             // @see https://bugs.php.net/bug.php?id=51800
-            $this->files = array(
-                Process::STDOUT => tempnam(sys_get_temp_dir(), 'out_sf_proc'),
-                Process::STDERR => tempnam(sys_get_temp_dir(), 'err_sf_proc'),
+            $pipes = array(
+                Process::STDOUT => Process::OUT,
+                Process::STDERR => Process::ERR,
             );
-            foreach ($this->files as $offset => $file) {
-                if (false === $file || false === $this->fileHandles[$offset] = 
@fopen($file, 'rb')) {
-                    throw new RuntimeException('A temporary file could not be 
opened to write the process output to, verify that your TEMP environment 
variable is writable');
+            $tmpDir = sys_get_temp_dir();
+            $error = 'unknown reason';
+            set_error_handler(function ($type, $msg) use (&$error) { $error = 
$msg; });
+            for ($i = 0;; ++$i) {
+                foreach ($pipes as $pipe => $name) {
+                    $file = sprintf('%s\\sf_proc_%02X.%s', $tmpDir, $i, $name);
+                    if (file_exists($file) && !unlink($file)) {
+                        continue 2;
+                    }
+                    $h = fopen($file, 'xb');
+                    if (!$h && false === strpos($error, 'File exists')) {
+                        restore_error_handler();
+                        throw new RuntimeException(sprintf('A temporary file 
could not be opened to write the process output: %s', $error));
+                    }
+                    if (!$h || !$this->fileHandles[$pipe] = fopen($file, 
'rb')) {
+                        continue 2;
+                    }
+                    if (isset($this->files[$pipe])) {
+                        unlink($this->files[$pipe]);
+                    }
+                    $this->files[$pipe] = $file;
                 }
+                break;
             }
+            restore_error_handler();
         }
 
         parent::__construct($input);
diff --git a/symfony/process/Process.php b/symfony/process/Process.php
index 7abbecb..7b67ffa 100644
--- a/symfony/process/Process.php
+++ b/symfony/process/Process.php
@@ -158,7 +158,7 @@
             $this->setEnv($env);
         }
 
-        $this->input = $input;
+        $this->setInput($input);
         $this->setTimeout($timeout);
         $this->useFileHandles = '\\' === DIRECTORY_SEPARATOR;
         $this->pty = false;
@@ -477,10 +477,10 @@
      * In comparison with the getOutput method which always return the whole
      * output, this one returns the new output since the last call.
      *
+     * @return string The process output since the last call
+     *
      * @throws LogicException in case the output has been disabled
      * @throws LogicException In case the process is not started
-     *
-     * @return string The process output since the last call
      */
     public function getIncrementalOutput()
     {
@@ -536,10 +536,10 @@
      * whole error output, this one returns the new error output since the last
      * call.
      *
+     * @return string The process error output since the last call
+     *
      * @throws LogicException in case the output has been disabled
      * @throws LogicException In case the process is not started
-     *
-     * @return string The process error output since the last call
      */
     public function getIncrementalErrorOutput()
     {
@@ -593,7 +593,7 @@
      * This method relies on the Unix exit code status standardization
      * and might not be relevant for other operating systems.
      *
-     * @return null|string A string representation for the exit status code, 
null if the Process is not terminated.
+     * @return null|string A string representation for the exit status code, 
null if the Process is not terminated
      *
      * @see http://tldp.org/LDP/abs/html/exitcodes.html
      * @see http://en.wikipedia.org/wiki/Unix_signal
@@ -881,7 +881,7 @@
      *
      * @param int|float|null $timeout The timeout in seconds
      *
-     * @return self The current Process instance.
+     * @return self The current Process instance
      *
      * @throws LogicException           if the output is disabled
      * @throws InvalidArgumentException if the timeout is negative
@@ -1049,7 +1049,7 @@
             throw new LogicException('Input can not be set while the process 
is running.');
         }
 
-        $this->input = ProcessUtils::validateInput(sprintf('%s::%s', 
__CLASS__, __FUNCTION__), $input);
+        $this->input = ProcessUtils::validateInput(__METHOD__, $input);
 
         return $this;
     }
@@ -1226,7 +1226,7 @@
     /**
      * Updates the status of the process, reads pipes.
      *
-     * @param bool $blocking Whether to use a blocking read call.
+     * @param bool $blocking Whether to use a blocking read call
      */
     protected function updateStatus($blocking)
     {
@@ -1312,8 +1312,8 @@
     /**
      * Reads pipes, executes callback.
      *
-     * @param bool $blocking Whether to use blocking calls or not.
-     * @param bool $close    Whether to close file handles or not.
+     * @param bool $blocking Whether to use blocking calls or not
+     * @param bool $close    Whether to close file handles or not
      */
     private function readPipes($blocking, $close)
     {
@@ -1439,7 +1439,7 @@
     /**
      * Ensures the process is running or terminated, throws a LogicException 
if the process has a not started.
      *
-     * @param string $functionName The function name that was called.
+     * @param string $functionName The function name that was called
      *
      * @throws LogicException If the process has not run.
      */
@@ -1453,7 +1453,7 @@
     /**
      * Ensures the process is terminated, throws a LogicException if the 
process has a status different than `terminated`.
      *
-     * @param string $functionName The function name that was called.
+     * @param string $functionName The function name that was called
      *
      * @throws LogicException If the process is not yet terminated.
      */
diff --git a/symfony/process/ProcessBuilder.php 
b/symfony/process/ProcessBuilder.php
index 69843ca..40f3cec 100644
--- a/symfony/process/ProcessBuilder.php
+++ b/symfony/process/ProcessBuilder.php
@@ -175,7 +175,7 @@
      */
     public function setInput($input)
     {
-        $this->input = ProcessUtils::validateInput(sprintf('%s::%s', 
__CLASS__, __FUNCTION__), $input);
+        $this->input = ProcessUtils::validateInput(__METHOD__, $input);
 
         return $this;
     }
diff --git a/symfony/process/ProcessUtils.php b/symfony/process/ProcessUtils.php
index 6cbfa22..8d426b5 100644
--- a/symfony/process/ProcessUtils.php
+++ b/symfony/process/ProcessUtils.php
@@ -80,7 +80,7 @@
      * @param string $caller The name of method call that validates the input
      * @param mixed  $input  The input to validate
      *
-     * @return string The validated input
+     * @return mixed The validated input
      *
      * @throws InvalidArgumentException In case the input is not valid
      */
@@ -90,6 +90,9 @@
             if (is_resource($input)) {
                 return $input;
             }
+            if (is_string($input)) {
+                return $input;
+            }
             if (is_scalar($input)) {
                 return (string) $input;
             }
diff --git a/symfony/process/Tests/ProcessTest.php 
b/symfony/process/Tests/ProcessTest.php
index ef16ec8..de95769 100644
--- a/symfony/process/Tests/ProcessTest.php
+++ b/symfony/process/Tests/ProcessTest.php
@@ -54,6 +54,9 @@
 
     public function testThatProcessDoesNotThrowWarningDuringRun()
     {
+        if ('\\' === DIRECTORY_SEPARATOR) {
+            $this->markTestSkipped('This test is transient on Windows');
+        }
         @trigger_error('Test Error', E_USER_NOTICE);
         $process = $this->getProcess(self::$phpBin." -r 'sleep(3)'");
         $process->run();
@@ -207,6 +210,24 @@
 
         $this->assertEquals($expectedLength, strlen($p->getOutput()));
         $this->assertEquals($expectedLength, strlen($p->getErrorOutput()));
+    }
+
+    public function testLiveStreamAsInput()
+    {
+        $stream = fopen('php://memory', 'r+');
+        fwrite($stream, 'hello');
+        rewind($stream);
+
+        $p = $this->getProcess(sprintf('%s -r %s', self::$phpBin, 
escapeshellarg('stream_copy_to_stream(STDIN, STDOUT);')));
+        $p->setInput($stream);
+        $p->start(function ($type, $data) use ($stream) {
+            if ('hello' === $data) {
+                fclose($stream);
+            }
+        });
+        $p->wait();
+
+        $this->assertSame('hello', $p->getOutput());
     }
 
     /**
@@ -1144,8 +1165,9 @@
     /**
      * @dataProvider provideVariousIncrementals
      */
-    public function testIncrementalOutputDoesNotRequireAnotherCall($stream, 
$method) {
-        $process = new Process(self::$phpBin.' -r '.escapeshellarg('$n = 0; 
while ($n < 3) { file_put_contents(\''.$stream.'\', $n, 1); $n++; usleep(1000); 
}'), null, null, null, null);
+    public function testIncrementalOutputDoesNotRequireAnotherCall($stream, 
$method)
+    {
+        $process = $this->getProcess(self::$phpBin.' -r '.escapeshellarg('$n = 
0; while ($n < 3) { file_put_contents(\''.$stream.'\', $n, 1); $n++; 
usleep(1000); }'), null, null, null, null);
         $process->start();
         $result = '';
         $limit = microtime(true) + 3;
@@ -1159,7 +1181,8 @@
         $process->stop();
     }
 
-    public function provideVariousIncrementals() {
+    public function provideVariousIncrementals()
+    {
         return array(
             array('php://stdout', 'getIncrementalOutput'),
             array('php://stderr', 'getIncrementalErrorOutput'),
@@ -1188,7 +1211,7 @@
             } catch (RuntimeException $e) {
                 $this->assertSame('This PHP has been compiled with 
--enable-sigchild. You must use setEnhanceSigchildCompatibility() to use this 
method.', $e->getMessage());
                 if ($enhance) {
-                    $process->setEnhanceSigChildCompatibility(true);
+                    $process->setEnhanceSigchildCompatibility(true);
                 } else {
                     self::$notEnhancedSigchild = true;
                 }

-- 
To view, visit https://gerrit.wikimedia.org/r/336948
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I77d538c755d5bdce668fcf6584167ffa1ed79ecd
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/vendor
Gerrit-Branch: master
Gerrit-Owner: Reedy <[email protected]>
Gerrit-Reviewer: BryanDavis <[email protected]>
Gerrit-Reviewer: Legoktm <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to