Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 8dbcc59

Browse files
[Process] Accept command line arrays and per-run env vars, fixing signaling and escaping
1 parent 2fb4fb9 commit 8dbcc59

12 files changed

+281
-133
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ script:
9696
- if [[ ! $deps && ! $PHP = hhvm* ]]; then echo "$COMPONENTS" | parallel --gnu '$PHPUNIT --exclude-group tty,benchmark,intl-data {}'"$REPORT"; fi
9797
- if [[ ! $deps && ! $PHP = hhvm* ]]; then echo -e "\\nRunning tests requiring tty"; $PHPUNIT --group tty; fi
9898
- if [[ ! $deps && $PHP = hhvm* ]]; then $PHPUNIT --exclude-group benchmark,intl-data; fi
99-
- if [[ ! $deps && $PHP = ${MIN_PHP%.*} ]]; then echo -e "1\\n0" | xargs -I{} sh -c 'echo "\\nPHP --enable-sigchild enhanced={}" && ENHANCE_SIGCHLD={} php-$MIN_PHP/sapi/cli/php .phpunit/phpunit-4.8/phpunit --colors=always src/Symfony/Component/Process/'; fi
99+
- if [[ ! $deps && $PHP = ${MIN_PHP%.*} ]]; then echo -e "1\\n0" | xargs -I{} sh -c 'echo "\\nPHP --enable-sigchild enhanced={}" && SYMFONY_DEPRECATIONS_HELPER=weak ENHANCE_SIGCHLD={} php-$MIN_PHP/sapi/cli/php .phpunit/phpunit-4.8/phpunit --colors=always src/Symfony/Component/Process/'; fi
100100
- if [[ $deps = high ]]; then echo "$COMPONENTS" | parallel --gnu -j10% 'cd {}; composer update --no-progress --ansi; $PHPUNIT --exclude-group tty,benchmark,intl-data'$LEGACY"$REPORT"; fi
101101
- if [[ $deps = low ]]; then echo "$COMPONENTS" | parallel --gnu -j10% 'cd {}; composer update --no-progress --ansi --prefer-lowest --prefer-stable; $PHPUNIT --exclude-group tty,benchmark,intl-data'"$REPORT"; fi
102102
# Test the PhpUnit bridge using the original phpunit script

UPGRADE-3.3.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,11 @@ HttpKernel
4646
* The `Psr6CacheClearer::addPool()` method has been deprecated. Pass an array of pools indexed
4747
by name to the constructor instead.
4848

49+
Process
50+
-------
51+
52+
* The `ProcessUtils::escapeArgument()` method has been deprecated, use a command line array or give env vars to the `Process::start/run()` method instead.
53+
4954
Security
5055
--------
5156

UPGRADE-4.0.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,11 @@ HttpKernel
208208
* The `Psr6CacheClearer::addPool()` method has been removed. Pass an array of pools indexed
209209
by name to the constructor instead.
210210

211+
Process
212+
-------
213+
214+
* The `ProcessUtils::escapeArgument()` method has been removed, use a command line array or give env vars to the `Process::start/run()` method instead.
215+
211216
Security
212217
--------
213218

src/Symfony/Component/Process/CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
CHANGELOG
22
=========
33

4+
3.3.0
5+
-----
6+
7+
* added command line arrays in the `Process` class
8+
* added `$env` argument to `Process::start()`, `run()`, `mustRun()` and `restart()` methods
9+
* deprecated the `ProcessUtils::escapeArgument()` method
10+
411
2.5.0
512
-----
613

src/Symfony/Component/Process/PhpProcess.php

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -38,20 +38,16 @@ public function __construct($script, $cwd = null, array $env = null, $timeout =
3838
$executableFinder = new PhpExecutableFinder();
3939
if (false === $php = $executableFinder->find()) {
4040
$php = null;
41+
} else {
42+
$php = explode(' ', $php);
4143
}
4244
if ('phpdbg' === PHP_SAPI) {
4345
$file = tempnam(sys_get_temp_dir(), 'dbg');
4446
file_put_contents($file, $script);
4547
register_shutdown_function('unlink', $file);
46-
$php .= ' '.ProcessUtils::escapeArgument($file);
48+
$php[] = $file;
4749
$script = null;
4850
}
49-
if ('\\' !== DIRECTORY_SEPARATOR && null !== $php) {
50-
// exec is mandatory to deal with sending a signal to the process
51-
// see https://github.com/symfony/symfony/issues/5030 about prepending
52-
// command with exec
53-
$php = 'exec '.$php;
54-
}
5551

5652
parent::__construct($php, $cwd, $env, $script, $timeout, $options);
5753
}
@@ -67,12 +63,13 @@ public function setPhpBinary($php)
6763
/**
6864
* {@inheritdoc}
6965
*/
70-
public function start(callable $callback = null)
66+
public function start(callable $callback = null/*, array $env = array()*/)
7167
{
7268
if (null === $this->getCommandLine()) {
7369
throw new RuntimeException('Unable to find the PHP executable.');
7470
}
71+
$env = 1 < func_num_args() ? func_get_arg(1) : null;
7572

76-
parent::start($callback);
73+
parent::start($callback, $env);
7774
}
7875
}

0 commit comments

Comments
 (0)