Skip to content

Commit 7c29f08

Browse files
[Process] Fix AbstractPipes::write() for a situation seen on HHVM (at least)
1 parent 8e01a2a commit 7c29f08

File tree

3 files changed

+4
-6
lines changed

3 files changed

+4
-6
lines changed

src/Symfony/Component/Process/Pipes/AbstractPipes.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ protected function write()
111111
if ($input) {
112112
for (;;) {
113113
$data = fread($input, self::CHUNK_SIZE);
114-
if (false === $data || '' === $data) {
114+
if (!isset($data[0])) {
115115
break;
116116
}
117117
$written = fwrite($stdin, $data);
@@ -134,9 +134,7 @@ protected function write()
134134
if (null === $this->input && !isset($this->inputBuffer[0])) {
135135
fclose($this->pipes[0]);
136136
unset($this->pipes[0]);
137-
}
138-
139-
if (!$w) {
137+
} elseif (!$w) {
140138
return array($this->pipes[0]);
141139
}
142140
}

src/Symfony/Component/Process/Pipes/UnixPipes.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ public function readAndWrite($blocking, $close = false)
120120
do {
121121
$data = fread($pipe, self::CHUNK_SIZE);
122122
$read[$type] .= $data;
123-
} while (false !== $data && '' !== $data);
123+
} while (isset($data[0]));
124124

125125
if (!isset($read[$type][0])) {
126126
unset($read[$type]);

src/Symfony/Component/Process/Pipes/WindowsPipes.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ public function readAndWrite($blocking, $close = false)
139139
foreach ($this->fileHandles as $type => $fileHandle) {
140140
$data = stream_get_contents($fileHandle, -1, $this->readBytes[$type]);
141141

142-
if (false !== $data && '' !== $data) {
142+
if (isset($data[0])) {
143143
$this->readBytes[$type] += strlen($data);
144144
$read[$type] = $data;
145145
}

0 commit comments

Comments
 (0)