This PR was squashed before being merged into the 3.4 branch (closes #23708).
Discussion
----------
Added deprecation to cwd not existing Fixes #18249
| Q | A
| ------------- | ---
| Branch? | 3.4
| Bug fix? | no
| New feature? |no <!-- don't forget updating src/**/CHANGELOG.md files -->
| BC breaks? | no
| Deprecations? | yes
| Tests pass? | yes
| Fixed tickets | #18249
| License | MIT
| Doc PR | -
Commits
-------
261eae970f
Added deprecation to cwd not existing Fixes #18249
This commit is contained in:
commit
87712e4006
@ -300,6 +300,8 @@ Process
|
|||||||
* The `Symfony\Component\Process\ProcessBuilder` class has been deprecated,
|
* The `Symfony\Component\Process\ProcessBuilder` class has been deprecated,
|
||||||
use the `Symfony\Component\Process\Process` class directly instead.
|
use the `Symfony\Component\Process\Process` class directly instead.
|
||||||
|
|
||||||
|
* Calling `Process::start()` without setting a valid working directory (via `setWorkingDirectory()` or constructor) beforehand is deprecated and will throw an exception in 4.0.
|
||||||
|
|
||||||
Profiler
|
Profiler
|
||||||
--------
|
--------
|
||||||
|
|
||||||
|
@ -639,6 +639,8 @@ Ldap
|
|||||||
Process
|
Process
|
||||||
-------
|
-------
|
||||||
|
|
||||||
|
* Passing a not existing working directory to the constructor of the `Symfony\Component\Process\Process` class is not supported anymore.
|
||||||
|
|
||||||
* The `Symfony\Component\Process\ProcessBuilder` class has been removed,
|
* The `Symfony\Component\Process\ProcessBuilder` class has been removed,
|
||||||
use the `Symfony\Component\Process\Process` class directly instead.
|
use the `Symfony\Component\Process\Process` class directly instead.
|
||||||
|
|
||||||
|
@ -5,6 +5,7 @@ CHANGELOG
|
|||||||
-----
|
-----
|
||||||
|
|
||||||
* deprecated the ProcessBuilder class
|
* deprecated the ProcessBuilder class
|
||||||
|
* deprecated calling `Process::start()` without setting a valid working directory beforehand (via `setWorkingDirectory()` or constructor)
|
||||||
|
|
||||||
3.3.0
|
3.3.0
|
||||||
-----
|
-----
|
||||||
|
@ -332,6 +332,14 @@ class Process implements \IteratorAggregate
|
|||||||
$ptsWorkaround = fopen(__FILE__, 'r');
|
$ptsWorkaround = fopen(__FILE__, 'r');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!is_dir($this->cwd)) {
|
||||||
|
if ('\\' === DIRECTORY_SEPARATOR) {
|
||||||
|
throw new RuntimeException('The provided cwd does not exist.');
|
||||||
|
}
|
||||||
|
|
||||||
|
@trigger_error('The provided cwd does not exist. Command is currently ran against getcwd(). This behavior is deprecated since version 3.4 and will be removed in 4.0.', E_USER_DEPRECATED);
|
||||||
|
}
|
||||||
|
|
||||||
$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, $this->options);
|
||||||
|
|
||||||
foreach ($envBackup as $k => $v) {
|
foreach ($envBackup as $k => $v) {
|
||||||
|
@ -48,6 +48,46 @@ class ProcessTest extends TestCase
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @group legacy
|
||||||
|
* @expectedDeprecation The provided cwd does not exist. Command is currently ran against getcwd(). This behavior is deprecated since version 3.4 and will be removed in 4.0.
|
||||||
|
*/
|
||||||
|
public function testInvalidCwd()
|
||||||
|
{
|
||||||
|
if ('\\' === DIRECTORY_SEPARATOR) {
|
||||||
|
$this->markTestSkipped('Windows handles this automatically.');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check that it works fine if the CWD exists
|
||||||
|
$cmd = new Process('echo test', __DIR__);
|
||||||
|
$cmd->run();
|
||||||
|
|
||||||
|
$cmd = new Process('echo test', __DIR__.'/notfound/');
|
||||||
|
$cmd->run();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @expectedException \Symfony\Component\Process\Exception\RuntimeException
|
||||||
|
* @expectedExceptionMessage The provided cwd does not exist.
|
||||||
|
*/
|
||||||
|
public function testInvalidCwdOnWindows()
|
||||||
|
{
|
||||||
|
if ('\\' !== DIRECTORY_SEPARATOR) {
|
||||||
|
$this->markTestSkipped('Unix handles this automatically.');
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
// Check that it works fine if the CWD exists
|
||||||
|
$cmd = new Process('echo test', __DIR__);
|
||||||
|
$cmd->run();
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
$this->fail($e);
|
||||||
|
}
|
||||||
|
|
||||||
|
$cmd = new Process('echo test', __DIR__.'/notfound/');
|
||||||
|
$cmd->run();
|
||||||
|
}
|
||||||
|
|
||||||
public function testThatProcessDoesNotThrowWarningDuringRun()
|
public function testThatProcessDoesNotThrowWarningDuringRun()
|
||||||
{
|
{
|
||||||
if ('\\' === DIRECTORY_SEPARATOR) {
|
if ('\\' === DIRECTORY_SEPARATOR) {
|
||||||
|
Reference in New Issue
Block a user