Skip to content

Commit aa82cd3

Browse files
Merge branch '2.3' into 2.7
* 2.3: [Process] Fix PhpProcess with phpdbg runtime Conflicts: composer.json src/Symfony/Bridge/ProxyManager/composer.json
2 parents a8d21b5 + a05e73f commit aa82cd3

File tree

9 files changed

+30
-26
lines changed

9 files changed

+30
-26
lines changed

composer.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@
7474
"doctrine/doctrine-bundle": "~1.2",
7575
"monolog/monolog": "~1.11",
7676
"ircmaxell/password-compat": "~1.0",
77-
"zendframework/zend-stdlib": "~2.5",
77+
"zendframework/zend-stdlib": "~2.2",
7878
"ocramius/proxy-manager": "~0.4|~1.0",
7979
"egulias/email-validator": "~1.2"
8080
},

phpunit

+6-4
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
*/
1212

1313
// Please update when phpunit needs to be reinstalled with fresh deps:
14-
// Cache-Id-Version: 2015-11-09 12:13 UTC
14+
// Cache-Id-Version: 2015-11-18 14:14 UTC
1515

1616
use Symfony\Component\Process\ProcessUtils;
1717

@@ -23,12 +23,15 @@ $PHPUNIT_VERSION = PHP_VERSION_ID >= 70000 ? '5.0' : '4.8';
2323
$PHPUNIT_DIR = __DIR__.'/.phpunit';
2424
$PHP = defined('PHP_BINARY') ? PHP_BINARY : 'php';
2525
$PHP = ProcessUtils::escapeArgument($PHP);
26+
if ('phpdbg' === PHP_SAPI) {
27+
$PHP .= ' -qrr';
28+
}
2629

2730
$COMPOSER = file_exists($COMPOSER = __DIR__.'/composer.phar') || ($COMPOSER = rtrim('\\' === DIRECTORY_SEPARATOR ? `where.exe composer.phar` : `which composer.phar`))
2831
? $PHP.' '.ProcessUtils::escapeArgument($COMPOSER)
2932
: 'composer';
3033

31-
if (!file_exists("$PHPUNIT_DIR/phpunit-$PHPUNIT_VERSION/phpunit") || md5_file(__FILE__) !== @file_get_contents("$PHPUNIT_DIR/.md5")) {
34+
if (!file_exists("$PHPUNIT_DIR/phpunit-$PHPUNIT_VERSION/phpunit") || md5_file(__FILE__) !== @file_get_contents("$PHPUNIT_DIR/.$PHPUNIT_VERSION.md5")) {
3235
// Build a standalone phpunit without symfony/yaml
3336

3437
$oldPwd = getcwd();
@@ -49,7 +52,6 @@ if (!file_exists("$PHPUNIT_DIR/phpunit-$PHPUNIT_VERSION/phpunit") || md5_file(__
4952
$zip->close();
5053
chdir("phpunit-$PHPUNIT_VERSION");
5154
passthru("$COMPOSER remove --no-update symfony/yaml");
52-
passthru("$COMPOSER require --no-update phpunit/phpunit-mock-objects \"<=3.0.0\"");
5355
passthru("$COMPOSER require --dev --no-update symfony/phpunit-bridge \">=2.8@dev\"");
5456
passthru("$COMPOSER install --prefer-source --no-progress --ansi");
5557
file_put_contents('phpunit', <<<EOPHP
@@ -66,7 +68,7 @@ EOPHP
6668
passthru(sprintf('\\' === DIRECTORY_SEPARATOR ? '(del /S /F /Q %s & rmdir %1$s) >nul': 'rm -rf %s', str_replace('/', DIRECTORY_SEPARATOR, "phpunit-$PHPUNIT_VERSION/vendor/symfony/phpunit-bridge")));
6769
symlink(realpath('../src/Symfony/Bridge/PhpUnit'), "phpunit-$PHPUNIT_VERSION/vendor/symfony/phpunit-bridge");
6870
}
69-
file_put_contents('.md5', md5_file(__FILE__));
71+
file_put_contents(".$PHPUNIT_VERSION.md5", md5_file(__FILE__));
7072
chdir($oldPwd);
7173

7274
}

src/Symfony/Bridge/ProxyManager/composer.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"require": {
1919
"php": ">=5.3.9",
2020
"symfony/dependency-injection": "~2.3",
21-
"zendframework/zend-stdlib": "~2.5",
21+
"zendframework/zend-stdlib": "~2.2",
2222
"ocramius/proxy-manager": "~0.4|~1.0"
2323
},
2424
"require-dev": {

src/Symfony/Component/Process/PhpExecutableFinder.php

+4-3
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ public function find($includeArgs = true)
4141
}
4242

4343
// PHP_BINARY return the current sapi executable
44-
if (defined('PHP_BINARY') && PHP_BINARY && in_array(PHP_SAPI, array('cli', 'cli-server')) && is_file(PHP_BINARY)) {
45-
return PHP_BINARY;
44+
if (defined('PHP_BINARY') && PHP_BINARY && in_array(PHP_SAPI, array('cli', 'cli-server', 'phpdbg')) && is_file(PHP_BINARY)) {
45+
return PHP_BINARY.($includeArgs ? ' '.implode(' ', $this->findArguments()) : '');
4646
}
4747

4848
if ($php = getenv('PHP_PATH')) {
@@ -76,9 +76,10 @@ public function findArguments()
7676
{
7777
$arguments = array();
7878

79-
// HHVM support
8079
if (defined('HHVM_VERSION')) {
8180
$arguments[] = '--php';
81+
} elseif ('phpdbg' === PHP_SAPI) {
82+
$arguments[] = '-qrr';
8283
}
8384

8485
return $arguments;

src/Symfony/Component/Process/PhpProcess.php

+7
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,13 @@ public function __construct($script, $cwd = null, array $env = null, $timeout =
3939
if (false === $php = $executableFinder->find()) {
4040
$php = null;
4141
}
42+
if ('phpdbg' === PHP_SAPI) {
43+
$file = tempnam(sys_get_temp_dir(), 'dbg');
44+
file_put_contents($file, $script);
45+
register_shutdown_function('unlink', $file);
46+
$php .= ' '.ProcessUtils::escapeArgument($file);
47+
$script = null;
48+
}
4249

4350
parent::__construct($php, $cwd, $env, $script, $timeout, $options);
4451
}

src/Symfony/Component/Process/Process.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ public function start($callback = null)
285285
if (!$this->useFileHandles && $this->enhanceSigchildCompatibility && $this->isSigchildEnabled()) {
286286
// Workaround for the bug, when PTS functionality is enabled.
287287
// @see : https://bugs.php.net/69442
288-
$ptsWorkaround = fopen('php://fd/0', 'r');
288+
$ptsWorkaround = fopen(__FILE__, 'r');
289289
}
290290

291291
$this->process = proc_open($commandline, $descriptors, $this->processPipes->pipes, $this->cwd, $this->env, $this->options);

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

+4-16
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ abstract class AbstractProcessTest extends \PHPUnit_Framework_TestCase
2828
public static function setUpBeforeClass()
2929
{
3030
$phpBin = new PhpExecutableFinder();
31-
self::$phpBin = $phpBin->find();
31+
self::$phpBin = 'phpdbg' === PHP_SAPI ? 'php' : $phpBin->find();
3232
}
3333

3434
public function testThatProcessDoesNotThrowWarningDuringRun()
@@ -81,7 +81,7 @@ public function testStopWithTimeoutIsActuallyWorking()
8181
// exec is mandatory here since we send a signal to the process
8282
// see https://github.com/symfony/symfony/issues/5030 about prepending
8383
// command with exec
84-
$p = $this->getProcess('exec php '.__DIR__.'/NonStopableProcess.php 3');
84+
$p = $this->getProcess('exec '.self::$phpBin.' '.__DIR__.'/NonStopableProcess.php 3');
8585
$p->start();
8686
usleep(100000);
8787
$start = microtime(true);
@@ -470,7 +470,7 @@ public function testTTYCommand()
470470
$this->markTestSkipped('Windows does have /dev/tty support');
471471
}
472472

473-
$process = $this->getProcess('echo "foo" >> /dev/null && php -r "usleep(100000);"');
473+
$process = $this->getProcess('echo "foo" >> /dev/null && '.self::$phpBin.' -r "usleep(100000);"');
474474
$process->setTty(true);
475475
$process->start();
476476
$this->assertTrue($process->isRunning());
@@ -730,7 +730,7 @@ public function testProcessThrowsExceptionWhenExternallySignaled()
730730

731731
$termSignal = defined('SIGKILL') ? SIGKILL : 9;
732732

733-
$process = $this->getProcess('exec php -r "while (true) {}"');
733+
$process = $this->getProcess('exec '.self::$phpBin.' -r "while (true) {}"');
734734
$process->start();
735735
posix_kill($process->getPid(), $termSignal);
736736

@@ -756,18 +756,6 @@ public function testRestart()
756756
$this->assertNotEquals($process1->getOutput(), $process2->getOutput());
757757
}
758758

759-
public function testPhpDeadlock()
760-
{
761-
$this->markTestSkipped('Can cause PHP to hang');
762-
763-
// Sleep doesn't work as it will allow the process to handle signals and close
764-
// file handles from the other end.
765-
$process = $this->getProcess(self::$phpBin.' -r "while (true) {}"');
766-
$process->start();
767-
768-
// PHP will deadlock when it tries to cleanup $process
769-
}
770-
771759
public function testRunProcessWithTimeout()
772760
{
773761
$timeout = 0.5;

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

+2
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,8 @@ public function testFindArguments()
6868

6969
if (defined('HHVM_VERSION')) {
7070
$this->assertEquals($f->findArguments(), array('--php'), '::findArguments() returns HHVM arguments');
71+
} elseif ('phpdbg' === PHP_SAPI) {
72+
$this->assertEquals($f->findArguments(), array('-qrr'), '::findArguments() returns phpdbg arguments');
7173
} else {
7274
$this->assertEquals($f->findArguments(), array(), '::findArguments() returns no arguments');
7375
}

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

+4
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@ public function testNonBlockingWorks()
3030

3131
public function testCommandLine()
3232
{
33+
if ('phpdbg' === PHP_SAPI) {
34+
$this->markTestSkipped('phpdbg SAPI is not supported by this test.');
35+
}
36+
3337
$process = new PhpProcess(<<<PHP
3438
<?php echo 'foobar';
3539
PHP

0 commit comments

Comments
 (0)