feature #23111 [Process] Deprecate ProcessBuilder (nicolas-grekas)
This PR was merged into the 3.4 branch.
Discussion
----------
[Process] Deprecate ProcessBuilder
| Q | A
| ------------- | ---
| Branch? | 3.4
| Bug fix? | no
| New feature? | no
| BC breaks? | no
| Deprecations? | yes
| Tests pass? | yes
| Fixed tickets | -
| License | MIT
| Doc PR | -
Commits
-------
3aa8861a42
[Process] Deprecate ProcessBuilder
This commit is contained in:
commit
1195c7d97e
@ -26,6 +26,12 @@ FrameworkBundle
|
|||||||
* The `KernelTestCase::getPhpUnitXmlDir()` and `KernelTestCase::getPhpUnitCliConfigArgument()`
|
* The `KernelTestCase::getPhpUnitXmlDir()` and `KernelTestCase::getPhpUnitCliConfigArgument()`
|
||||||
methods are deprecated since 3.4 and will be removed in 4.0.
|
methods are deprecated since 3.4 and will be removed in 4.0.
|
||||||
|
|
||||||
|
Process
|
||||||
|
-------
|
||||||
|
|
||||||
|
* The `Symfony\Component\Process\ProcessBuilder` class has been deprecated,
|
||||||
|
use the `Symfony\Component\Process\Process` class directly instead.
|
||||||
|
|
||||||
Validator
|
Validator
|
||||||
---------
|
---------
|
||||||
|
|
||||||
|
@ -420,6 +420,9 @@ Ldap
|
|||||||
Process
|
Process
|
||||||
-------
|
-------
|
||||||
|
|
||||||
|
* The `Symfony\Component\Process\ProcessBuilder` class has been removed,
|
||||||
|
use the `Symfony\Component\Process\Process` class directly instead.
|
||||||
|
|
||||||
* The `ProcessUtils::escapeArgument()` method has been removed, use a command line array or give env vars to the `Process::start/run()` method instead.
|
* The `ProcessUtils::escapeArgument()` method has been removed, use a command line array or give env vars to the `Process::start/run()` method instead.
|
||||||
|
|
||||||
* Environment variables are always inherited in sub-processes.
|
* Environment variables are always inherited in sub-processes.
|
||||||
|
@ -13,7 +13,6 @@ namespace Symfony\Bundle\WebServerBundle;
|
|||||||
|
|
||||||
use Symfony\Component\Process\PhpExecutableFinder;
|
use Symfony\Component\Process\PhpExecutableFinder;
|
||||||
use Symfony\Component\Process\Process;
|
use Symfony\Component\Process\Process;
|
||||||
use Symfony\Component\Process\ProcessBuilder;
|
|
||||||
use Symfony\Component\Process\Exception\RuntimeException;
|
use Symfony\Component\Process\Exception\RuntimeException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -151,11 +150,11 @@ class WebServer
|
|||||||
throw new \RuntimeException('Unable to find the PHP binary.');
|
throw new \RuntimeException('Unable to find the PHP binary.');
|
||||||
}
|
}
|
||||||
|
|
||||||
$builder = new ProcessBuilder(array($binary, '-S', $config->getAddress(), $config->getRouter()));
|
$process = new Process(array($binary, '-S', $config->getAddress(), $config->getRouter()));
|
||||||
$builder->setWorkingDirectory($config->getDocumentRoot());
|
$process->setWorkingDirectory($config->getDocumentRoot());
|
||||||
$builder->setTimeout(null);
|
$process->setTimeout(null);
|
||||||
|
|
||||||
return $builder->getProcess();
|
return $process;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function getDefaultPidFile()
|
private function getDefaultPidFile()
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
"php": ">=5.5.9",
|
"php": ">=5.5.9",
|
||||||
"symfony/console": "~2.8.8|~3.0.8|~3.1.2|~3.2|~4.0",
|
"symfony/console": "~2.8.8|~3.0.8|~3.1.2|~3.2|~4.0",
|
||||||
"symfony/http-kernel": "~3.3|~4.0",
|
"symfony/http-kernel": "~3.3|~4.0",
|
||||||
"symfony/process": "~2.8|~3.0|~4.0"
|
"symfony/process": "~3.3|~4.0"
|
||||||
},
|
},
|
||||||
"autoload": {
|
"autoload": {
|
||||||
"psr-4": { "Symfony\\Bundle\\WebServerBundle\\": "" },
|
"psr-4": { "Symfony\\Bundle\\WebServerBundle\\": "" },
|
||||||
|
@ -15,7 +15,6 @@ use Symfony\Component\Console\Output\ConsoleOutputInterface;
|
|||||||
use Symfony\Component\Console\Output\OutputInterface;
|
use Symfony\Component\Console\Output\OutputInterface;
|
||||||
use Symfony\Component\Process\Exception\ProcessFailedException;
|
use Symfony\Component\Process\Exception\ProcessFailedException;
|
||||||
use Symfony\Component\Process\Process;
|
use Symfony\Component\Process\Process;
|
||||||
use Symfony\Component\Process\ProcessBuilder;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The ProcessHelper class provides helpers to run external processes.
|
* The ProcessHelper class provides helpers to run external processes.
|
||||||
@ -45,7 +44,7 @@ class ProcessHelper extends Helper
|
|||||||
$formatter = $this->getHelperSet()->get('debug_formatter');
|
$formatter = $this->getHelperSet()->get('debug_formatter');
|
||||||
|
|
||||||
if (is_array($cmd)) {
|
if (is_array($cmd)) {
|
||||||
$process = ProcessBuilder::create($cmd)->getProcess();
|
$process = new Process($cmd);
|
||||||
} elseif ($cmd instanceof Process) {
|
} elseif ($cmd instanceof Process) {
|
||||||
$process = $cmd;
|
$process = $cmd;
|
||||||
} else {
|
} else {
|
||||||
|
@ -17,7 +17,6 @@ use Symfony\Component\Console\Helper\HelperSet;
|
|||||||
use Symfony\Component\Console\Output\StreamOutput;
|
use Symfony\Component\Console\Output\StreamOutput;
|
||||||
use Symfony\Component\Console\Helper\ProcessHelper;
|
use Symfony\Component\Console\Helper\ProcessHelper;
|
||||||
use Symfony\Component\Process\Process;
|
use Symfony\Component\Process\Process;
|
||||||
use Symfony\Component\Process\ProcessBuilder;
|
|
||||||
|
|
||||||
class ProcessHelperTest extends TestCase
|
class ProcessHelperTest extends TestCase
|
||||||
{
|
{
|
||||||
@ -85,8 +84,8 @@ EOT;
|
|||||||
EOT;
|
EOT;
|
||||||
|
|
||||||
$errorMessage = 'An error occurred';
|
$errorMessage = 'An error occurred';
|
||||||
$args = new ProcessBuilder(array('php', '-r', 'echo 42;'));
|
$args = new Process(array('php', '-r', 'echo 42;'));
|
||||||
$args = $args->getProcess()->getCommandLine();
|
$args = $args->getCommandLine();
|
||||||
$successOutputProcessDebug = str_replace("'php' '-r' 'echo 42;'", $args, $successOutputProcessDebug);
|
$successOutputProcessDebug = str_replace("'php' '-r' 'echo 42;'", $args, $successOutputProcessDebug);
|
||||||
|
|
||||||
return array(
|
return array(
|
||||||
|
@ -26,7 +26,7 @@
|
|||||||
"symfony/event-dispatcher": "~2.8|~3.0|~4.0",
|
"symfony/event-dispatcher": "~2.8|~3.0|~4.0",
|
||||||
"symfony/dependency-injection": "~3.3|~4.0",
|
"symfony/dependency-injection": "~3.3|~4.0",
|
||||||
"symfony/filesystem": "~2.8|~3.0|~4.0",
|
"symfony/filesystem": "~2.8|~3.0|~4.0",
|
||||||
"symfony/process": "~2.8|~3.0|~4.0",
|
"symfony/process": "~3.3|~4.0",
|
||||||
"psr/log": "~1.0"
|
"psr/log": "~1.0"
|
||||||
},
|
},
|
||||||
"suggest": {
|
"suggest": {
|
||||||
@ -36,7 +36,8 @@
|
|||||||
"psr/log": "For using the console logger"
|
"psr/log": "For using the console logger"
|
||||||
},
|
},
|
||||||
"conflict": {
|
"conflict": {
|
||||||
"symfony/dependency-injection": "<3.3"
|
"symfony/dependency-injection": "<3.3",
|
||||||
|
"symfony/process": "<3.3"
|
||||||
},
|
},
|
||||||
"autoload": {
|
"autoload": {
|
||||||
"psr-4": { "Symfony\\Component\\Console\\": "" },
|
"psr-4": { "Symfony\\Component\\Console\\": "" },
|
||||||
|
@ -1,6 +1,11 @@
|
|||||||
CHANGELOG
|
CHANGELOG
|
||||||
=========
|
=========
|
||||||
|
|
||||||
|
3.4.0
|
||||||
|
-----
|
||||||
|
|
||||||
|
* deprecated the ProcessBuilder class
|
||||||
|
|
||||||
3.3.0
|
3.3.0
|
||||||
-----
|
-----
|
||||||
|
|
||||||
|
@ -11,6 +11,8 @@
|
|||||||
|
|
||||||
namespace Symfony\Component\Process;
|
namespace Symfony\Component\Process;
|
||||||
|
|
||||||
|
@trigger_error(sprintf('The %s class is deprecated since version 3.4 and will be removed in 4.0. Use the Process class instead.', ProcessBuilder::class), E_USER_DEPRECATED);
|
||||||
|
|
||||||
use Symfony\Component\Process\Exception\InvalidArgumentException;
|
use Symfony\Component\Process\Exception\InvalidArgumentException;
|
||||||
use Symfony\Component\Process\Exception\LogicException;
|
use Symfony\Component\Process\Exception\LogicException;
|
||||||
|
|
||||||
@ -18,6 +20,8 @@ use Symfony\Component\Process\Exception\LogicException;
|
|||||||
* Process builder.
|
* Process builder.
|
||||||
*
|
*
|
||||||
* @author Kris Wallsmith <kris@symfony.com>
|
* @author Kris Wallsmith <kris@symfony.com>
|
||||||
|
*
|
||||||
|
* @deprecated since version 3.4, to be removed in 4.0. Use the Process class instead.
|
||||||
*/
|
*/
|
||||||
class ProcessBuilder
|
class ProcessBuilder
|
||||||
{
|
{
|
||||||
@ -120,13 +124,9 @@ class ProcessBuilder
|
|||||||
* @param bool $inheritEnv
|
* @param bool $inheritEnv
|
||||||
*
|
*
|
||||||
* @return $this
|
* @return $this
|
||||||
*
|
|
||||||
* @deprecated since version 3.3, to be removed in 4.0.
|
|
||||||
*/
|
*/
|
||||||
public function inheritEnvironmentVariables($inheritEnv = true)
|
public function inheritEnvironmentVariables($inheritEnv = true)
|
||||||
{
|
{
|
||||||
@trigger_error(sprintf('The %s() method is deprecated since version 3.3 and will be removed in 4.0.', __METHOD__), E_USER_DEPRECATED);
|
|
||||||
|
|
||||||
$this->inheritEnv = $inheritEnv;
|
$this->inheritEnv = $inheritEnv;
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
@ -221,13 +221,9 @@ class ProcessBuilder
|
|||||||
* @param string $value The option value
|
* @param string $value The option value
|
||||||
*
|
*
|
||||||
* @return $this
|
* @return $this
|
||||||
*
|
|
||||||
* @deprecated since version 3.3, to be removed in 4.0.
|
|
||||||
*/
|
*/
|
||||||
public function setOption($name, $value)
|
public function setOption($name, $value)
|
||||||
{
|
{
|
||||||
@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[$name] = $value;
|
$this->options[$name] = $value;
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
|
@ -14,11 +14,11 @@ namespace Symfony\Component\Process\Tests;
|
|||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
use Symfony\Component\Process\ProcessBuilder;
|
use Symfony\Component\Process\ProcessBuilder;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @group legacy
|
||||||
|
*/
|
||||||
class ProcessBuilderTest extends TestCase
|
class ProcessBuilderTest extends TestCase
|
||||||
{
|
{
|
||||||
/**
|
|
||||||
* @group legacy
|
|
||||||
*/
|
|
||||||
public function testInheritEnvironmentVars()
|
public function testInheritEnvironmentVars()
|
||||||
{
|
{
|
||||||
$proc = ProcessBuilder::create()
|
$proc = ProcessBuilder::create()
|
||||||
|
Reference in New Issue
Block a user