8000 bug #11381 [2.3] [Process] Use correct test for empty string in UnixP… · symfony/symfony@91e32f8 · GitHub
[go: up one dir, main page]

Skip to content

Commit 91e32f8

Browse files
committed
bug #11381 [2.3] [Process] Use correct test for empty string in UnixPipes (whs, romainneutron)
This PR was merged into the 2.3 branch. Discussion ---------- [2.3] [Process] Use correct test for empty string in UnixPipes | Q | A | ------------- | --- | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | n/a | License | MIT | Doc PR | n/a This PR supersedes #11264 : 2.3 compatibility + Windows compatibility + CS fix Commits ------- cec0a45 [Process] Adjust PR #11264, make it Windows compatible and fix CS 9e1ea4a [Process] Use correct test for empty string in UnixPipes
2 parents 45df2f3 + cec0a45 commit 91e32f8

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

src/Symfony/Component/Process/ProcessPipes.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -313,11 +313,11 @@ private function readStreams($blocking, $close = false)
313313
$type = array_search($pipe, $this->pipes);
314314

315315
$data = '';
316-
while ($dataread = fread($pipe, self::CHUNK_SIZE)) {
316+
while ('' !== $dataread = (string) fread($pipe, self::CHUNK_SIZE)) {
317317
$data .= $dataread;
318318
}
319319

320-
if ($data) {
320+
if ('' !== $data) {
321321
$read[$type] = $data;
322322
}
323323

src/Symfony/Component/Process/Tests/AbstractProcessTest.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,19 @@ public function testGetIncrementalOutput()
287287
}
288288
}
289289

290+
public function testZeroAsOutput()
291+
{
292+
if (defined('PHP_WINDOWS_VERSION_BUILD')) {
293+
// see http://stackoverflow.com/questions/7105433/windows-batch-echo-without-new-line
294+
$p = $this->getProcess('echo | set /p dummyName=0');
295+
} else {
296+
$p = $this->getProcess('printf 0');
297+
}
298+
299+
$p->run();
300+
$this->assertSame('0', $p->getOutput());
301+
}
302+
290303
public function testExitCodeCommandFailed()
291304
{
292305
if (defined('PHP_WINDOWS_VERSION_BUILD')) {

0 commit comments

Comments
 (0)
0