Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

[Process] remove deprecated features #22836

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 28, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions 14 src/Symfony/Component/Process/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,20 @@
CHANGELOG
=========

4.0.0
-----

* environment variables will always be inherited
* added a second `array $env = array()` argument to the `start()`, `run()`,
`mustRun()`, and `restart()` methods of the `Process` class
* added a second `array $env = array()` argument to the `start()` method of the
`PhpProcess` class
* the `ProcessUtils::escapeArgument()` method has been removed
* the `areEnvironmentVariablesInherited()`, `getOptions()`, and `setOptions()`
methods of the `Process` class have been removed
* support for passing `proc_open()` options has been removed
* removed the `ProcessBuilder` class, use the `Process` class instead

3.4.0
-----

Expand Down
11 changes: 3 additions & 8 deletions 11 src/Symfony/Component/Process/PhpProcess.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,8 @@ class PhpProcess extends Process
* @param string|null $cwd The working directory or null to use the working dir of the current PHP process
* @param array|null $env The environment variables or null to use the same environment as the current PHP process
* @param int $timeout The timeout in seconds
* @param array $options An array of options for proc_open
*/
public function __construct($script, $cwd = null, array $env = null, $timeout = 60, array $options = null)
public function __construct($script, $cwd = null, array $env = null, $timeout = 60)
{
$executableFinder = new PhpExecutableFinder();
if (false === $php = $executableFinder->find(false)) {
Expand All @@ -48,11 +47,8 @@ public function __construct($script, $cwd = null, array $env = null, $timeout =
$php[] = $file;
$script = null;
}
if (null !== $options) {
@trigger_error(sprintf('The $options parameter of the %s constructor is deprecated since version 3.3 and will be removed in 4.0.', __CLASS__), E_USER_DEPRECATED);
}

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

/**
Expand All @@ -66,12 +62,11 @@ public function setPhpBinary($php)
/**
* {@inheritdoc}
*/
public function start(callable $callback = null/*, array $env = array()*/)
public function start(callable $callback = null, array $env = array())
{
if (null === $this->getCommandLine()) {
throw new RuntimeException('Unable to find the PHP executable.');
}
$env = 1 < func_num_args() ? func_get_arg(1) : null;

parent::start($callback, $env);
}
Expand Down
100 changes: 14 additions & 86 deletions 100 src/Symfony/Component/Process/Process.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ class Process implements \IteratorAggregate
private $lastOutputTime;
private $timeout;
private $idleTimeout;
private $options = array('suppress_errors' => true);
private $exitcode;
private $fallbackStatus = array();
private $processInformation;
Expand All @@ -73,7 +72,6 @@ class Process implements \IteratorAggregate
private $incrementalErrorOutputOffset = 0;
private $tty;
private $pty;
private $inheritEnv = false;

private $useFileHandles = false;
/** @var PipesInterface */
Expand Down Expand Up @@ -141,11 +139,10 @@ class Process implements \IteratorAggregate
* @param array|null $env The environment variables or null to use the same environment as the current PHP process
* @param mixed|null $input The input as stream resource, scalar or \Traversable, or null for no input
* @param int|float|null $timeout The timeout in seconds or null to disable
* @param array $options An array of options for proc_open
*
* @throws RuntimeException When proc_open is not installed
*/
public function __construct($commandline, $cwd = null, array $env = null, $input = null, $timeout = 60, array $options = null)
public function __construct($commandline, $cwd = null, array $env = null, $input = null, $timeout = 60)
{
if (!function_exists('proc_open')) {
throw new RuntimeException('The Process class relies on proc_open, which is not available on your PHP installation.');
Expand All @@ -170,10 +167,6 @@ public function __construct($commandline, $cwd = null, array $env = null, $input
$this->useFileHandles = '\\' === DIRECTORY_SEPARATOR;
$this->pty = false;
$this->enhanceSigchildCompatibility = '\\' !== DIRECTORY_SEPARATOR && $this->isSigchildEnabled();
if (null !== $options) {
@trigger_error(sprintf('The $options parameter of the %s constructor is deprecated since version 3.3 and will be removed in 4.0.', __CLASS__), E_USER_DEPRECATED);
$this->options = array_replace($this->options, $options);
}
}

public function __destruct()
Expand Down Expand Up @@ -208,9 +201,8 @@ public function __clone()
*
* @final since version 3.3
*/
public function run($callback = null/*, array $env = array()*/)
public function run($callback = null, array $env = array())
{
$env = 1 < func_num_args() ? func_get_arg(1) : null;
$this->start($callback, $env);

return $this->wait();
Expand All @@ -232,12 +224,11 @@ public function run($callback = null/*, array $env = array()*/)
*
* @final since version 3.3
*/
public function mustRun(callable $callback = null/*, array $env = array()*/)
public function mustRun(callable $callback = null, array $env = array())
{
if (!$this->enhanceSigchildCompatibility && $this->isSigchildEnabled()) {
throw new RuntimeException('This PHP has been compiled with --enable-sigchild. You must use setEnhanceSigchildCompatibility() to use this method.');
}
$env = 1 < func_num_args() ? func_get_arg(1) : null;

if (0 !== $this->run($callback, $env)) {
throw new ProcessFailedException($this);
Expand Down Expand Up @@ -266,29 +257,17 @@ public function mustRun(callable $callback = null/*, array $env = array()*/)
* @throws RuntimeException When process is already running
* @throws LogicException In case a callback is provided and output has been disabled
*/
public function start(callable $callback = null/*, array $env = array()*/)
public function start(callable $callback = null, array $env = array())
{
if ($this->isRunning()) {
throw new RuntimeException('Process is already running');
}
if (2 <= func_num_args()) {
$env = func_get_arg(1);
} else {
if (__CLASS__ !== static::class) {
$r = new \ReflectionMethod($this, __FUNCTION__);
if (__CLASS__ !== $r->getDeclaringClass()->getName() && (2 > $r->getNumberOfParameters() || 'env' !== $r->getParameters()[0]->name)) {
@trigger_error(sprintf('The %s::start() method expects a second "$env" argument since version 3.3. It will be made mandatory in 4.0.', static::class), E_USER_DEPRECATED);
}
}
$env = null;
}

$this->resetProcessData();
$this->starttime = $this->lastOutputTime = microtime(true);
$this->callback = $this->buildCallback($callback);
$this->hasCallback = null !== $callback;
$descriptors = $this->getDescriptors();
$inheritEnv = $this->inheritEnv;

if (is_array($commandline = $this->commandline)) {
$commandline = implode(' ', array_map(array($this, 'escapeArgument'), $commandline));
Expand All @@ -301,25 +280,23 @@ public function start(callable $callback = null/*, array $env = array()*/)

if (null === $env) {
$env = $this->env;
} else {
if ($this->env) {
$env += $this->env;
}
$inheritEnv = true;
} elseif ($this->env) {
$env += $this->env;
}

$envBackup = array();
if (null !== $env && $inheritEnv) {
if (null !== $env) {
foreach ($env as $k => $v) {
$envBackup[$k] = getenv($k);
putenv(false === $v || null === $v ? $k : "$k=$v");
}
$env = null;
} elseif (null !== $env) {
@trigger_error('Not inheriting environment variables is deprecated since Symfony 3.3 and will always happen in 4.0. Set "Process::inheritEnvironmentVariables()" to true instead.', E_USER_DEPRECATED);
}

$options = array('suppress_errors' => true);

if ('\\' === DIRECTORY_SEPARATOR && $this->enhanceWindowsCompatibility) {
$this->options['bypass_shell'] = true;
$options['bypass_shell'] = true;
$commandline = $this->prepareWindowsCommandLine($commandline, $envBackup, $env);
} elseif (!$this->useFileHandles && $this->enhanceSigchildCompatibility && $this->isSigchildEnabled()) {
// last exit code is output on the fourth pipe and caught to work around --enable-sigchild
Expand All @@ -334,7 +311,7 @@ public function start(callable $callback = null/*, array $env = array()*/)
$ptsWorkaround = fopen(__FILE__, 'r');
}

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

foreach ($envBackup as $k => $v) {
putenv(false === $v ? $k : "$k=$v");
Expand Down Expand Up @@ -375,12 +352,11 @@ public function start(callable $callback = null/*, array $env = array()*/)
*
* @final since version 3.3
*/
public function restart(callable $callback = null/*, array $env = array()*/)
public function restart(callable $callback = null, array $env = array())
{
if ($this->isRunning()) {
throw new RuntimeException('Process is already running');
}
$env = 1 < func_num_args() ? func_get_arg(1) : null;

$process = clone $this;
$process->start($callback, $env);
Expand Down Expand Up @@ -1178,38 +1154,6 @@ public function setInput($input)
return $this;
}

/**
* Gets the options for proc_open.
*
* @return array The current options
*
* @deprecated since version 3.3, to be removed in 4.0.
*/
public function getOptions()
{
@trigger_error(sprintf('The %s() method is deprecated since version 3.3 and will be removed in 4.0.', __METHOD__), E_USER_DEPRECATED);

return $this->options;
}

/**
* Sets the options for proc_open.
*
* @param array $options The new options
*
* @return self The current Process instance
*
* @deprecated since version 3.3, to be removed in 4.0.
*/
public function setOptions(array $options)
{
@trigger_error(sprintf('The %s() method is deprecated since version 3.3 and will be removed in 4.0.', __METHOD__), E_USER_DEPRECATED);

$this->options = $options;

return $this;
}

/**
* Gets whether or not Windows compatibility is enabled.
*
Expand Down Expand Up @@ -1290,28 +1234,12 @@ public function setEnhanceSigchildCompatibility($enhance)
public function inheritEnvironmentVariables($inheritEnv = true)
{
if (!$inheritEnv) {
@trigger_error('Not inheriting environment variables is deprecated since Symfony 3.3 and will always happen in 4.0. Set "Process::inheritEnvironmentVariables()" to true instead.', E_USER_DEPRECATED);
throw new InvalidArgumentException('Not inheriting environment variables is not supported.');
}

$this->inheritEnv = (bool) $inheritEnv;

return $this;
}

/**
* Returns whether environment variables will be inherited or not.
*
* @return bool
*
* @deprecated since version 3.3, to be removed in 4.0. Environment variables will always be inherited.
*/
public function areEnvironmentVariablesInherited()
{
@trigger_error(sprintf('The %s() method is deprecated since version 3.3 and will be removed in 4.0. Environment variables will always be inherited.', __METHOD__), E_USER_DEPRECATED);

return $this->inheritEnv;
}

/**
* Performs a check between the timeout definition and the time the process started.
*
Expand Down
Loading
Morty Proxy This is a proxified and sanitized view of the page, visit original site.