diff --git a/src/Symfony/Component/Process/Pipes/UnixPipes.php b/src/Symfony/Component/Process/Pipes/UnixPipes.php index f8a0d1997dc36..925f4f0b055c7 100644 --- a/src/Symfony/Component/Process/Pipes/UnixPipes.php +++ b/src/Symfony/Component/Process/Pipes/UnixPipes.php @@ -38,7 +38,9 @@ public function __construct($ttyMode, $ptyMode, $input, $disableOutput) if (is_resource($input)) { $this->input = $input; } else { - $this->inputBuffer = (string) $input; + $this->input = fopen('php://temp', 'w+'); + fwrite($this->input, $input); + fseek($this->input, 0); } } @@ -147,16 +149,16 @@ public function readAndWrite($blocking, $close = false) // lose key association, we have to find back the key $type = (false !== $found = array_search($pipe, $this->pipes)) ? $found : 'input'; $data = ''; - while ('' !== $dataread = (string) fread($pipe, self::CHUNK_SIZE)) { - $data .= $dataread; - } - - if ('' !== $data) { - if ($type === 'input') { - $this->inputBuffer .= $data; - } else { - $read[$type] = $data; + if ($type !== 'input') { + while ('' !== $dataread = (string) fread($pipe, self::CHUNK_SIZE)) { + $data .= $dataread; + } + // Remove extra null chars returned by fread + if ('' !== $data) { + $read[$type] = rtrim($data, "\x00"); } + } elseif (isset($w[0])) { + stream_copy_to_stream($this->input, $w[0], 4096); } if (false === $data || (true === $close && feof($pipe) && '' === $data)) { @@ -171,19 +173,8 @@ public function readAndWrite($blocking, $close = false) } } - if (null !== $w && 0 < count($w)) { - while (strlen($this->inputBuffer)) { - $written = fwrite($w[0], $this->inputBuffer, 2 << 18); // write 512k - if ($written > 0) { - $this->inputBuffer = (string) substr($this->inputBuffer, $written); - } else { - break; - } - } - } - - // no input to read on resource, buffer is empty and stdin still open - if ('' === $this->inputBuffer && null === $this->input && isset($this->pipes[0])) { + // no input to read on resource and stdin still open + if (null === $this->input && isset($this->pipes[0])) { fclose($this->pipes[0]); unset($this->pipes[0]); } pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy