8000 bug #9367 [Process] Check if the pipe array is empty before calling s… · symfony/symfony@2375046 · GitHub
[go: up one dir, main page]

Skip to content

Commit 2375046

Browse files
committed
bug #9367 [Process] Check if the pipe array is empty before calling stream_select() (jfposton)
This PR was submitted for the master branch but it was merged into the 2.2 branch instead (closes #9367). Discussion ---------- [Process] Check if the pipe array is empty before calling stream_select() | Q | A | ------------- | --- | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #9280 | License | MIT | Doc PR | ProcessPipes generates a warning frequently which can cause issues for custom shutdown functions. Adding a check to see if the pipe array is empty should be functionally equivalent without having to generate the error. Fixes: #9280 Commits ------- 12f95e2 [Process] Check if the pipe array is empty before calling stream_select()
2 parents 43371bb + 52a18ea commit 2375046

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

src/Symfony/Component/Process/ProcessPipes.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,10 @@ private function readFileHandles($close = false)
247247
*/
248248
private function readStreams($blocking, $close = false)
249249
{
250+
if (empty($this->pipes)) {
251+
return array();
252+
}
253+
250254
$read = array();
251255

252256
$r = $this->pipes;

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,16 @@
1919
*/
2020
abstract class AbstractProcessTest extends \PHPUnit_Framework_TestCase
2121
{
22+
public function testThatProcessDoesNotThrowWarningDuringRun()
23+
{
24+
@trigger_error('Test Error', E_USER_NOTICE);
25+
$process = $this->getProcess("php -r 'sleep(3)'");
26+
$process->run();
27+
$actualError = error_get_last();
28+
$this->assertEquals('Test Error', $actualError['message']);
29+
$this->assertEquals(E_USER_NOTICE, $actualError['type']);
30+
}
31+
2232
/**
2333
* @expectedException \Symfony\Component\Process\Exception\InvalidArgumentException
2434
*/

0 commit comments

Comments
 (0)
0