From a019543ba40685517ffa3c92694b2dd3ff068cfb Mon Sep 17 00:00:00 2001 From: Alex Bowers Date: Fri, 28 Jul 2017 22:09:12 +0100 Subject: [PATCH 01/25] Added deprecation to cwd not existing # Conflicts: # src/Symfony/Component/Process/Process.php --- src/Symfony/Component/Process/Process.php | 6 +++++- .../Component/Process/Tests/ProcessTest.php | 21 +++++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Component/Process/Process.php b/src/Symfony/Component/Process/Process.php index e925e913863a9..7922d272785ab 100644 --- a/src/Symfony/Component/Process/Process.php +++ b/src/Symfony/Component/Process/Process.php @@ -334,7 +334,11 @@ 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); + if (!file_exists($this->cwd)) { + trigger_error("The provided cwd does not exist. Command is currently ran against getcwd()", E_DEPRECATED); + } + + $this->process = proc_open($commandline, $descriptors, $this->processPipes->pipes, $this->cwd, $env, $options); foreach ($envBackup as $k => $v) { putenv(false === $v ? $k : "$k=$v"); diff --git a/src/Symfony/Component/Process/Tests/ProcessTest.php b/src/Symfony/Component/Process/Tests/ProcessTest.php index 267257117d43d..2ca78d0ffd55b 100644 --- a/src/Symfony/Component/Process/Tests/ProcessTest.php +++ b/src/Symfony/Component/Process/Tests/ProcessTest.php @@ -48,6 +48,27 @@ protected function tearDown() } } + /** + * @see https://github.com/symfony/symfony/issues/18249 + */ + public function testCwdParameterBugDeprecationIssue18249() + { + // Check that it works fine if the CWD exists + $cmd = new Process("touch testing1.txt", __DIR__); + $this->assertEquals(0, $cmd->run()); + + try{ + $cmd = new Process("touch testing2.txt", __DIR__ . "/notfound/"); + $this->assertEquals(0, $cmd->run()); + } catch (\Throwable $e) { + $this->assertTrue(true); // A deprecated error was thrown + // Blank intentionally + } + + @unlink(__DIR__ . "/testing1.txt"); + @unlink(getcwd() . "/testing2.txt"); + } + public function testThatProcessDoesNotThrowWarningDuringRun() { if ('\\' === DIRECTORY_SEPARATOR) { From 602a7d4881edeac92851db4f226fc0302d04c7be Mon Sep 17 00:00:00 2001 From: Alex Bowers Date: Fri, 28 Jul 2017 22:12:49 +0100 Subject: [PATCH 02/25] Upgrade Docs updated --- UPGRADE-3.4.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/UPGRADE-3.4.md b/UPGRADE-3.4.md index 2c80252b5b8ab..2dbce56a41b6a 100644 --- a/UPGRADE-3.4.md +++ b/UPGRADE-3.4.md @@ -209,6 +209,9 @@ Process * The `Symfony\Component\Process\ProcessBuilder` class has been deprecated, use the `Symfony\Component\Process\Process` class directly instead. + + * The `Symfony\Component\Process\Process` __construct `cwd` argument will throw + a deprecation warning on `run` if the folder does not exist. Profiler -------- From 7103381706d29d008085d9caf1842fa1464e5483 Mon Sep 17 00:00:00 2001 From: Alex Bowers Date: Fri, 28 Jul 2017 22:14:23 +0100 Subject: [PATCH 03/25] Fixed codestyle issues --- src/Symfony/Component/Process/Process.php | 2 +- src/Symfony/Component/Process/Tests/ProcessTest.php | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Symfony/Component/Process/Process.php b/src/Symfony/Component/Process/Process.php index 7922d272785ab..1a24a0292c4e4 100644 --- a/src/Symfony/Component/Process/Process.php +++ b/src/Symfony/Component/Process/Process.php @@ -335,7 +335,7 @@ public function start(callable $callback = null/*, array $env = array()*/) } if (!file_exists($this->cwd)) { - trigger_error("The provided cwd does not exist. Command is currently ran against getcwd()", E_DEPRECATED); + trigger_error('The provided cwd does not exist. Command is currently ran against getcwd()', E_DEPRECATED); } $this->process = proc_open($commandline, $descriptors, $this->processPipes->pipes, $this->cwd, $env, $options); diff --git a/src/Symfony/Component/Process/Tests/ProcessTest.php b/src/Symfony/Component/Process/Tests/ProcessTest.php index 2ca78d0ffd55b..1810ffddc8501 100644 --- a/src/Symfony/Component/Process/Tests/ProcessTest.php +++ b/src/Symfony/Component/Process/Tests/ProcessTest.php @@ -54,19 +54,19 @@ protected function tearDown() public function testCwdParameterBugDeprecationIssue18249() { // Check that it works fine if the CWD exists - $cmd = new Process("touch testing1.txt", __DIR__); + $cmd = new Process('touch testing1.txt', __DIR__); $this->assertEquals(0, $cmd->run()); - try{ - $cmd = new Process("touch testing2.txt", __DIR__ . "/notfound/"); + try { + $cmd = new Process('touch testing2.txt', __DIR__.'/notfound/'); $this->assertEquals(0, $cmd->run()); } catch (\Throwable $e) { $this->assertTrue(true); // A deprecated error was thrown // Blank intentionally } - @unlink(__DIR__ . "/testing1.txt"); - @unlink(getcwd() . "/testing2.txt"); + @unlink(__DIR__.'/testing1.txt'); + @unlink(getcwd().'/testing2.txt'); } public function testThatProcessDoesNotThrowWarningDuringRun() From 56a4a0146014bb84dc80f240b0550ac286389505 Mon Sep 17 00:00:00 2001 From: Alex Bowers Date: Fri, 28 Jul 2017 22:23:35 +0100 Subject: [PATCH 04/25] Renamed test --- src/Symfony/Component/Process/Tests/ProcessTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Component/Process/Tests/ProcessTest.php b/src/Symfony/Component/Process/Tests/ProcessTest.php index 1810ffddc8501..83d45cdab306b 100644 --- a/src/Symfony/Component/Process/Tests/ProcessTest.php +++ b/src/Symfony/Component/Process/Tests/ProcessTest.php @@ -51,7 +51,7 @@ protected function tearDown() /** * @see https://github.com/symfony/symfony/issues/18249 */ - public function testCwdParameterBugDeprecationIssue18249() + public function testInvalidCwd() { // Check that it works fine if the CWD exists $cmd = new Process('touch testing1.txt', __DIR__); From f9225dda1cc9fa7c0bacdd50d72e0570543bccdf Mon Sep 17 00:00:00 2001 From: Alex Bowers Date: Fri, 28 Jul 2017 23:26:48 +0100 Subject: [PATCH 05/25] Improved tests to check for deprecation properly --- src/Symfony/Component/Process/Process.php | 2 +- src/Symfony/Component/Process/Tests/ProcessTest.php | 12 +++++------- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/src/Symfony/Component/Process/Process.php b/src/Symfony/Component/Process/Process.php index 1a24a0292c4e4..9e931409f9172 100644 --- a/src/Symfony/Component/Process/Process.php +++ b/src/Symfony/Component/Process/Process.php @@ -335,7 +335,7 @@ public function start(callable $callback = null/*, array $env = array()*/) } if (!file_exists($this->cwd)) { - trigger_error('The provided cwd does not exist. Command is currently ran against getcwd()', E_DEPRECATED); + @trigger_error('The provided cwd does not exist. Command is currently ran against getcwd()', E_USER_DEPRECATED); } $this->process = proc_open($commandline, $descriptors, $this->processPipes->pipes, $this->cwd, $env, $options); diff --git a/src/Symfony/Component/Process/Tests/ProcessTest.php b/src/Symfony/Component/Process/Tests/ProcessTest.php index 83d45cdab306b..2fb7fdda15fec 100644 --- a/src/Symfony/Component/Process/Tests/ProcessTest.php +++ b/src/Symfony/Component/Process/Tests/ProcessTest.php @@ -50,6 +50,9 @@ protected function tearDown() /** * @see https://github.com/symfony/symfony/issues/18249 + * + * @group legacy + * @expectedDeprecation The provided cwd does not exist. Command is currently ran against getcwd() */ public function testInvalidCwd() { @@ -57,13 +60,8 @@ public function testInvalidCwd() $cmd = new Process('touch testing1.txt', __DIR__); $this->assertEquals(0, $cmd->run()); - try { - $cmd = new Process('touch testing2.txt', __DIR__.'/notfound/'); - $this->assertEquals(0, $cmd->run()); - } catch (\Throwable $e) { - $this->assertTrue(true); // A deprecated error was thrown - // Blank intentionally - } + $cmd = new Process('touch testing2.txt', __DIR__.'/notfound/'); + $this->assertEquals(0, $cmd->run()); @unlink(__DIR__.'/testing1.txt'); @unlink(getcwd().'/testing2.txt'); From 4c9f3d0cb878fc1c0fffdc11569c208c60e53af8 Mon Sep 17 00:00:00 2001 From: Alex Bowers Date: Sat, 2 Sep 2017 03:06:17 +0100 Subject: [PATCH 06/25] Check if cwd is a directory, not a file --- src/Symfony/Component/Process/Process.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Component/Process/Process.php b/src/Symfony/Component/Process/Process.php index 9e931409f9172..f60cec3ae2c74 100644 --- a/src/Symfony/Component/Process/Process.php +++ b/src/Symfony/Component/Process/Process.php @@ -334,7 +334,7 @@ public function start(callable $callback = null/*, array $env = array()*/) $ptsWorkaround = fopen(__FILE__, 'r'); } - if (!file_exists($this->cwd)) { + if (!is_dir($this->cwd)) { @trigger_error('The provided cwd does not exist. Command is currently ran against getcwd()', E_USER_DEPRECATED); } From f44bfd99a5c0bbef2500aa3f2ddda1820bb52734 Mon Sep 17 00:00:00 2001 From: Alex Bowers Date: Sat, 2 Sep 2017 03:07:18 +0100 Subject: [PATCH 07/25] Remove unnecessary comment --- src/Symfony/Component/Process/Tests/ProcessTest.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Symfony/Component/Process/Tests/ProcessTest.php b/src/Symfony/Component/Process/Tests/ProcessTest.php index 2fb7fdda15fec..a296a3c82765b 100644 --- a/src/Symfony/Component/Process/Tests/ProcessTest.php +++ b/src/Symfony/Component/Process/Tests/ProcessTest.php @@ -49,8 +49,6 @@ protected function tearDown() } /** - * @see https://github.com/symfony/symfony/issues/18249 - * * @group legacy * @expectedDeprecation The provided cwd does not exist. Command is currently ran against getcwd() */ From 296cfe6b217b92ac12e585f7da1f0ff65937e357 Mon Sep 17 00:00:00 2001 From: Alex Bowers Date: Sat, 2 Sep 2017 03:08:51 +0100 Subject: [PATCH 08/25] Improved documenting the deprecation --- src/Symfony/Component/Process/Process.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Component/Process/Process.php b/src/Symfony/Component/Process/Process.php index f60cec3ae2c74..6bb9312693dbe 100644 --- a/src/Symfony/Component/Process/Process.php +++ b/src/Symfony/Component/Process/Process.php @@ -335,7 +335,7 @@ public function start(callable $callback = null/*, array $env = array()*/) } if (!is_dir($this->cwd)) { - @trigger_error('The provided cwd does not exist. Command is currently ran against getcwd()', E_USER_DEPRECATED); + @trigger_error('The provided cwd does not exist. Command is currently ran against getcwd(). This behaviour 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, $options); From 5918f16005047b45c831d5d9e1470cdd65b9b564 Mon Sep 17 00:00:00 2001 From: Alex Bowers Date: Sat, 2 Sep 2017 03:21:16 +0100 Subject: [PATCH 09/25] Improve error and make test pass again --- src/Symfony/Component/Process/Process.php | 5 ++++- src/Symfony/Component/Process/Tests/ProcessTest.php | 6 +++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/Symfony/Component/Process/Process.php b/src/Symfony/Component/Process/Process.php index 6bb9312693dbe..58453bf8822b7 100644 --- a/src/Symfony/Component/Process/Process.php +++ b/src/Symfony/Component/Process/Process.php @@ -318,6 +318,9 @@ public function start(callable $callback = null/*, array $env = array()*/) } 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; $commandline = $this->prepareWindowsCommandLine($commandline, $envBackup, $env); @@ -335,7 +338,7 @@ public function start(callable $callback = null/*, array $env = array()*/) } if (!is_dir($this->cwd)) { - @trigger_error('The provided cwd does not exist. Command is currently ran against getcwd(). This behaviour is deprecated since version 3.4 and will be removed in 4.0', E_USER_DEPRECATED); + @trigger_error('The provided cwd does not exist. Command is currently ran against getcwd(). This behaviour 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, $options); diff --git a/src/Symfony/Component/Process/Tests/ProcessTest.php b/src/Symfony/Component/Process/Tests/ProcessTest.php index a296a3c82765b..a7a2a255f0dd8 100644 --- a/src/Symfony/Component/Process/Tests/ProcessTest.php +++ b/src/Symfony/Component/Process/Tests/ProcessTest.php @@ -50,15 +50,15 @@ protected function tearDown() /** * @group legacy - * @expectedDeprecation The provided cwd does not exist. Command is currently ran against getcwd() + * @expectedDeprecation The provided cwd does not exist. Command is currently ran against getcwd(). This behaviour is deprecated since version 3.4 and will be removed in 4.0. */ public function testInvalidCwd() { // Check that it works fine if the CWD exists - $cmd = new Process('touch testing1.txt', __DIR__); + $cmd = new Process('echo test > testing1.txt', __DIR__); $this->assertEquals(0, $cmd->run()); - $cmd = new Process('touch testing2.txt', __DIR__.'/notfound/'); + $cmd = new Process('echo test > testing2.txt', __DIR__.'/notfound/'); $this->assertEquals(0, $cmd->run()); @unlink(__DIR__.'/testing1.txt'); From 1dd14be2111d74bf0e96650037d18407ab06eb94 Mon Sep 17 00:00:00 2001 From: Alex Bowers Date: Sat, 2 Sep 2017 19:00:49 +0100 Subject: [PATCH 10/25] Use options properly --- src/Symfony/Component/Process/Process.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/Symfony/Component/Process/Process.php b/src/Symfony/Component/Process/Process.php index 58453bf8822b7..ce7a9acbfc365 100644 --- a/src/Symfony/Component/Process/Process.php +++ b/src/Symfony/Component/Process/Process.php @@ -319,8 +319,6 @@ public function start(callable $callback = null/*, array $env = array()*/) @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; $commandline = $this->prepareWindowsCommandLine($commandline, $envBackup, $env); @@ -341,7 +339,7 @@ public function start(callable $callback = null/*, array $env = array()*/) @trigger_error('The provided cwd does not exist. Command is currently ran against getcwd(). This behaviour 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, $options); + $this->process = proc_open($commandline, $descriptors, $this->processPipes->pipes, $this->cwd, $env, $this->options); foreach ($envBackup as $k => $v) { putenv(false === $v ? $k : "$k=$v"); From 06dd2eb6e8cab4417c5a5442dcf6f8d267131107 Mon Sep 17 00:00:00 2001 From: Alex Bowers Date: Sat, 2 Sep 2017 19:01:09 +0100 Subject: [PATCH 11/25] Run the commands without checking exit codes --- src/Symfony/Component/Process/Tests/ProcessTest.php | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/Symfony/Component/Process/Tests/ProcessTest.php b/src/Symfony/Component/Process/Tests/ProcessTest.php index a7a2a255f0dd8..caa43d655d934 100644 --- a/src/Symfony/Component/Process/Tests/ProcessTest.php +++ b/src/Symfony/Component/Process/Tests/ProcessTest.php @@ -55,14 +55,11 @@ protected function tearDown() public function testInvalidCwd() { // Check that it works fine if the CWD exists - $cmd = new Process('echo test > testing1.txt', __DIR__); - $this->assertEquals(0, $cmd->run()); + $cmd = new Process('echo test', __DIR__); + $cmd->run(); - $cmd = new Process('echo test > testing2.txt', __DIR__.'/notfound/'); - $this->assertEquals(0, $cmd->run()); - - @unlink(__DIR__.'/testing1.txt'); - @unlink(getcwd().'/testing2.txt'); + $cmd = new Process('echo test', __DIR__.'/notfound/'); + $cmd->run(); } public function testThatProcessDoesNotThrowWarningDuringRun() From d684e7036adf274b964422f1838a6a3703339c39 Mon Sep 17 00:00:00 2001 From: Alex Bowers Date: Sat, 2 Sep 2017 22:35:52 +0100 Subject: [PATCH 12/25] Improve testing --- .../Component/Process/Tests/ProcessTest.php | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/Symfony/Component/Process/Tests/ProcessTest.php b/src/Symfony/Component/Process/Tests/ProcessTest.php index caa43d655d934..6e21e8dad5679 100644 --- a/src/Symfony/Component/Process/Tests/ProcessTest.php +++ b/src/Symfony/Component/Process/Tests/ProcessTest.php @@ -54,6 +54,27 @@ protected function tearDown() */ public function testInvalidCwd() { + if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') { + $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 \PHPUnit_Framework_Error_Warning + */ + public function testInvalidCwdOnWindows() + { + if (strtoupper(substr(PHP_OS, 0, 3)) !== 'WIN') { + $this->markTestSkipped("Unix handles this automatically.") + } + // Check that it works fine if the CWD exists $cmd = new Process('echo test', __DIR__); $cmd->run(); From 7e0141c1407ddbca31c3e8e1b83b702ec72dca77 Mon Sep 17 00:00:00 2001 From: Alex Bowers Date: Sat, 2 Sep 2017 22:40:36 +0100 Subject: [PATCH 13/25] Forgot to put semi colon on --- src/Symfony/Component/Process/Tests/ProcessTest.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Symfony/Component/Process/Tests/ProcessTest.php b/src/Symfony/Component/Process/Tests/ProcessTest.php index 6e21e8dad5679..9178f93ab089c 100644 --- a/src/Symfony/Component/Process/Tests/ProcessTest.php +++ b/src/Symfony/Component/Process/Tests/ProcessTest.php @@ -55,7 +55,7 @@ protected function tearDown() public function testInvalidCwd() { if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') { - $this->markTestSkipped("Windows handles this automatically.") + $this->markTestSkipped("Windows handles this automatically."); } // Check that it works fine if the CWD exists @@ -72,7 +72,7 @@ public function testInvalidCwd() public function testInvalidCwdOnWindows() { if (strtoupper(substr(PHP_OS, 0, 3)) !== 'WIN') { - $this->markTestSkipped("Unix handles this automatically.") + $this->markTestSkipped("Unix handles this automatically."); } // Check that it works fine if the CWD exists From 1e4abf6e139511759fe236918c1f68d7dbf4b59f Mon Sep 17 00:00:00 2001 From: Alex Bowers Date: Sat, 2 Sep 2017 22:50:54 +0100 Subject: [PATCH 14/25] Fix test --- src/Symfony/Component/Process/Tests/ProcessTest.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Symfony/Component/Process/Tests/ProcessTest.php b/src/Symfony/Component/Process/Tests/ProcessTest.php index 9178f93ab089c..25544cb6a03c8 100644 --- a/src/Symfony/Component/Process/Tests/ProcessTest.php +++ b/src/Symfony/Component/Process/Tests/ProcessTest.php @@ -67,6 +67,8 @@ public function testInvalidCwd() } /** + * @group legacy + * @expectedDeprecation The provided cwd does not exist. Command is currently ran against getcwd(). This behaviour is deprecated since version 3.4 and will be removed in 4.0. * @expectedException \PHPUnit_Framework_Error_Warning */ public function testInvalidCwdOnWindows() From 53b2c2e2e0187742c6325562f73cb4bb3af02991 Mon Sep 17 00:00:00 2001 From: Alex Bowers Date: Sat, 2 Sep 2017 23:06:55 +0100 Subject: [PATCH 15/25] Fixing coding style --- src/Symfony/Component/Process/Tests/ProcessTest.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Symfony/Component/Process/Tests/ProcessTest.php b/src/Symfony/Component/Process/Tests/ProcessTest.php index 25544cb6a03c8..cb09d90e9dfe3 100644 --- a/src/Symfony/Component/Process/Tests/ProcessTest.php +++ b/src/Symfony/Component/Process/Tests/ProcessTest.php @@ -55,7 +55,7 @@ protected function tearDown() public function testInvalidCwd() { if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') { - $this->markTestSkipped("Windows handles this automatically."); + $this->markTestSkipped('Windows handles this automatically.'); } // Check that it works fine if the CWD exists @@ -74,7 +74,7 @@ public function testInvalidCwd() public function testInvalidCwdOnWindows() { if (strtoupper(substr(PHP_OS, 0, 3)) !== 'WIN') { - $this->markTestSkipped("Unix handles this automatically."); + $this->markTestSkipped('Unix handles this automatically.'); } // Check that it works fine if the CWD exists From 8830131eea6500e70d8f56b3cb9c5e8067be107b Mon Sep 17 00:00:00 2001 From: Alex Bowers Date: Sun, 3 Sep 2017 19:28:53 +0100 Subject: [PATCH 16/25] Windows exception --- src/Symfony/Component/Process/Process.php | 4 ++++ src/Symfony/Component/Process/Tests/ProcessTest.php | 9 ++++----- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/Symfony/Component/Process/Process.php b/src/Symfony/Component/Process/Process.php index ce7a9acbfc365..0b30ca3872d13 100644 --- a/src/Symfony/Component/Process/Process.php +++ b/src/Symfony/Component/Process/Process.php @@ -336,6 +336,10 @@ public function start(callable $callback = null/*, array $env = array()*/) } 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 behaviour is deprecated since version 3.4 and will be removed in 4.0.', E_USER_DEPRECATED); } diff --git a/src/Symfony/Component/Process/Tests/ProcessTest.php b/src/Symfony/Component/Process/Tests/ProcessTest.php index cb09d90e9dfe3..c8df1544c01ed 100644 --- a/src/Symfony/Component/Process/Tests/ProcessTest.php +++ b/src/Symfony/Component/Process/Tests/ProcessTest.php @@ -54,7 +54,7 @@ protected function tearDown() */ public function testInvalidCwd() { - if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') { + if ('\\' === DIRECTORY_SEPARATOR) { $this->markTestSkipped('Windows handles this automatically.'); } @@ -67,13 +67,12 @@ public function testInvalidCwd() } /** - * @group legacy - * @expectedDeprecation The provided cwd does not exist. Command is currently ran against getcwd(). This behaviour is deprecated since version 3.4 and will be removed in 4.0. - * @expectedException \PHPUnit_Framework_Error_Warning + * @expectedException \Symfony\Component\Process\Exception\RuntimeException + * @expectedExceptionMessage The provided cwd does not exist. */ public function testInvalidCwdOnWindows() { - if (strtoupper(substr(PHP_OS, 0, 3)) !== 'WIN') { + if ('\\' !== DIRECTORY_SEPARATOR) { $this->markTestSkipped('Unix handles this automatically.'); } From d9746a2d4889dcc6d5169442774ddf348a6a3fb6 Mon Sep 17 00:00:00 2001 From: Alex Bowers Date: Sun, 3 Sep 2017 19:30:52 +0100 Subject: [PATCH 17/25] Removed newline --- src/Symfony/Component/Process/Process.php | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Symfony/Component/Process/Process.php b/src/Symfony/Component/Process/Process.php index 0b30ca3872d13..984a03d73eb39 100644 --- a/src/Symfony/Component/Process/Process.php +++ b/src/Symfony/Component/Process/Process.php @@ -318,7 +318,6 @@ public function start(callable $callback = null/*, array $env = array()*/) } 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); } - if ('\\' === DIRECTORY_SEPARATOR && $this->enhanceWindowsCompatibility) { $this->options['bypass_shell'] = true; $commandline = $this->prepareWindowsCommandLine($commandline, $envBackup, $env); From babbfea10f22d57984882def41422b84708c3b51 Mon Sep 17 00:00:00 2001 From: Alex Bowers Date: Sun, 3 Sep 2017 19:33:11 +0100 Subject: [PATCH 18/25] Changed the upgrade doc wording --- UPGRADE-3.4.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/UPGRADE-3.4.md b/UPGRADE-3.4.md index 2dbce56a41b6a..d042180f9adfe 100644 --- a/UPGRADE-3.4.md +++ b/UPGRADE-3.4.md @@ -209,8 +209,8 @@ Process * The `Symfony\Component\Process\ProcessBuilder` class has been deprecated, use the `Symfony\Component\Process\Process` class directly instead. - - * The `Symfony\Component\Process\Process` __construct `cwd` argument will throw + + * The `Symfony\Component\Process\Process` constructor's $cwd argument will throw a deprecation warning on `run` if the folder does not exist. Profiler From d57ac4d8cc0196830a6b0e84a765392897104a76 Mon Sep 17 00:00:00 2001 From: Alex Bowers Date: Sun, 3 Sep 2017 19:39:26 +0100 Subject: [PATCH 19/25] Codestyle fix --- src/Symfony/Component/Process/Process.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Component/Process/Process.php b/src/Symfony/Component/Process/Process.php index 984a03d73eb39..6e2aa989b99a7 100644 --- a/src/Symfony/Component/Process/Process.php +++ b/src/Symfony/Component/Process/Process.php @@ -336,7 +336,7 @@ public function start(callable $callback = null/*, array $env = array()*/) if (!is_dir($this->cwd)) { if ('\\' === DIRECTORY_SEPARATOR) { - throw new RuntimeException("The provided cwd does not exist."); + throw new RuntimeException('The provided cwd does not exist.'); } @trigger_error('The provided cwd does not exist. Command is currently ran against getcwd(). This behaviour is deprecated since version 3.4 and will be removed in 4.0.', E_USER_DEPRECATED); From b93e7ad5cb0dc7ae9244bc1674044e4bbd379d56 Mon Sep 17 00:00:00 2001 From: Alex Bowers Date: Thu, 7 Sep 2017 23:40:09 +0100 Subject: [PATCH 20/25] Fixes --- UPGRADE-3.4.md | 3 +-- UPGRADE-4.0.md | 1 + src/Symfony/Component/Process/CHANGELOG.md | 1 + src/Symfony/Component/Process/Process.php | 2 +- 4 files changed, 4 insertions(+), 3 deletions(-) diff --git a/UPGRADE-3.4.md b/UPGRADE-3.4.md index d042180f9adfe..dbdf4fa512fb8 100644 --- a/UPGRADE-3.4.md +++ b/UPGRADE-3.4.md @@ -210,8 +210,7 @@ Process * The `Symfony\Component\Process\ProcessBuilder` class has been deprecated, use the `Symfony\Component\Process\Process` class directly instead. - * The `Symfony\Component\Process\Process` constructor's $cwd argument will throw - a deprecation warning on `run` if the folder does not exist. + * Passing a not existing working directory to the constructor of the `Symfony\Component\Process\Process` class is deprecated and will not be supported anymore in Symfony 4.0. Profiler -------- diff --git a/UPGRADE-4.0.md b/UPGRADE-4.0.md index 9f8017c47e8a4..aeffbda458efc 100644 --- a/UPGRADE-4.0.md +++ b/UPGRADE-4.0.md @@ -566,6 +566,7 @@ Ldap 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, use the `Symfony\Component\Process\Process` class directly instead. diff --git a/src/Symfony/Component/Process/CHANGELOG.md b/src/Symfony/Component/Process/CHANGELOG.md index 7193c498d4326..7740b2c26c399 100644 --- a/src/Symfony/Component/Process/CHANGELOG.md +++ b/src/Symfony/Component/Process/CHANGELOG.md @@ -5,6 +5,7 @@ CHANGELOG ----- * deprecated the ProcessBuilder class + * Passing a not existing working directory to the constructor of the `Symfony\Component\Process\Process` class is deprecated and will not be supported anymore in Symfony 4.0. 3.3.0 ----- diff --git a/src/Symfony/Component/Process/Process.php b/src/Symfony/Component/Process/Process.php index 6e2aa989b99a7..5af8b2df4e145 100644 --- a/src/Symfony/Component/Process/Process.php +++ b/src/Symfony/Component/Process/Process.php @@ -339,7 +339,7 @@ public function start(callable $callback = null/*, array $env = array()*/) throw new RuntimeException('The provided cwd does not exist.'); } - @trigger_error('The provided cwd does not exist. Command is currently ran against getcwd(). This behaviour is deprecated since version 3.4 and will be removed in 4.0.', E_USER_DEPRECATED); + @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); From e8a27023893bb9e7af20218a0494ac6f1bd4cac2 Mon Sep 17 00:00:00 2001 From: Alex Bowers Date: Thu, 14 Sep 2017 10:35:32 +0100 Subject: [PATCH 21/25] Behaviour -> behavior --- src/Symfony/Component/Process/Tests/ProcessTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Component/Process/Tests/ProcessTest.php b/src/Symfony/Component/Process/Tests/ProcessTest.php index c8df1544c01ed..90c4663357636 100644 --- a/src/Symfony/Component/Process/Tests/ProcessTest.php +++ b/src/Symfony/Component/Process/Tests/ProcessTest.php @@ -50,7 +50,7 @@ protected function tearDown() /** * @group legacy - * @expectedDeprecation The provided cwd does not exist. Command is currently ran against getcwd(). This behaviour is deprecated since version 3.4 and will be removed in 4.0. + * @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() { From 647fdffc40cb3fe5da78150331c4e678ee4c9e9d Mon Sep 17 00:00:00 2001 From: Alex Bowers Date: Thu, 14 Sep 2017 13:37:51 +0100 Subject: [PATCH 22/25] New line --- UPGRADE-4.0.md | 1 + 1 file changed, 1 insertion(+) diff --git a/UPGRADE-4.0.md b/UPGRADE-4.0.md index aeffbda458efc..59f4607863ad1 100644 --- a/UPGRADE-4.0.md +++ b/UPGRADE-4.0.md @@ -566,6 +566,7 @@ Ldap 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, From 29ad993244e31b515511436ee53a7181bb0d10a5 Mon Sep 17 00:00:00 2001 From: Alex Bowers Date: Thu, 14 Sep 2017 19:18:04 +0100 Subject: [PATCH 23/25] Handle test that should pass, failing, better --- src/Symfony/Component/Process/Tests/ProcessTest.php | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/Symfony/Component/Process/Tests/ProcessTest.php b/src/Symfony/Component/Process/Tests/ProcessTest.php index 90c4663357636..4264ff4e2c19f 100644 --- a/src/Symfony/Component/Process/Tests/ProcessTest.php +++ b/src/Symfony/Component/Process/Tests/ProcessTest.php @@ -76,9 +76,13 @@ public function testInvalidCwdOnWindows() $this->markTestSkipped('Unix handles this automatically.'); } - // Check that it works fine if the CWD exists - $cmd = new Process('echo test', __DIR__); - $cmd->run(); + 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(); @@ -1530,7 +1534,7 @@ public function testRawCommandLine() ( [0] => - [1] => a - [2] => + [2] => [3] => b ) From 8e9ddd20fc476c71573c3890b617a96470197664 Mon Sep 17 00:00:00 2001 From: Alex Bowers Date: Thu, 5 Oct 2017 22:20:43 +0100 Subject: [PATCH 24/25] Improvement fixes --- UPGRADE-3.4.md | 2 +- src/Symfony/Component/Process/CHANGELOG.md | 2 +- src/Symfony/Component/Process/Tests/ProcessTest.php | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/UPGRADE-3.4.md b/UPGRADE-3.4.md index dbdf4fa512fb8..9ad662ffed825 100644 --- a/UPGRADE-3.4.md +++ b/UPGRADE-3.4.md @@ -210,7 +210,7 @@ Process * The `Symfony\Component\Process\ProcessBuilder` class has been deprecated, use the `Symfony\Component\Process\Process` class directly instead. - * Passing a not existing working directory to the constructor of the `Symfony\Component\Process\Process` class is deprecated and will not be supported anymore in Symfony 4.0. + * 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 -------- diff --git a/src/Symfony/Component/Process/CHANGELOG.md b/src/Symfony/Component/Process/CHANGELOG.md index 7740b2c26c399..c5cdb9944164b 100644 --- a/src/Symfony/Component/Process/CHANGELOG.md +++ b/src/Symfony/Component/Process/CHANGELOG.md @@ -5,7 +5,7 @@ CHANGELOG ----- * deprecated the ProcessBuilder class - * Passing a not existing working directory to the constructor of the `Symfony\Component\Process\Process` class is deprecated and will not be supported anymore in Symfony 4.0. + * deprecated calling `Process::start()` without setting a valid working directory beforehand (via `setWorkingDirectory()` or constructor) 3.3.0 ----- diff --git a/src/Symfony/Component/Process/Tests/ProcessTest.php b/src/Symfony/Component/Process/Tests/ProcessTest.php index 4264ff4e2c19f..5a5c3d6a61063 100644 --- a/src/Symfony/Component/Process/Tests/ProcessTest.php +++ b/src/Symfony/Component/Process/Tests/ProcessTest.php @@ -1534,7 +1534,7 @@ public function testRawCommandLine() ( [0] => - [1] => a - [2] => + [2] => [3] => b ) From f46239db35080cabfd187b946a96eae1cc1423e3 Mon Sep 17 00:00:00 2001 From: Alex Bowers Date: Thu, 5 Oct 2017 23:18:29 +0100 Subject: [PATCH 25/25] Ran fabbot --- src/Symfony/Component/Process/Process.php | 8 ++++---- src/Symfony/Component/Process/Tests/ProcessTest.php | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/Symfony/Component/Process/Process.php b/src/Symfony/Component/Process/Process.php index 5af8b2df4e145..79cb20cb66ebd 100644 --- a/src/Symfony/Component/Process/Process.php +++ b/src/Symfony/Component/Process/Process.php @@ -839,7 +839,7 @@ public function isRunning() */ public function isStarted() { - return $this->status != self::STATUS_READY; + return self::STATUS_READY != $this->status; } /** @@ -851,7 +851,7 @@ public function isTerminated() { $this->updateStatus(false); - return $this->status == self::STATUS_TERMINATED; + return self::STATUS_TERMINATED == $this->status; } /** @@ -1330,7 +1330,7 @@ public function areEnvironmentVariablesInherited() */ public function checkTimeout() { - if ($this->status !== self::STATUS_STARTED) { + if (self::STATUS_STARTED !== $this->status) { return; } @@ -1521,7 +1521,7 @@ private function readPipes($blocking, $close) $callback = $this->callback; foreach ($result as $type => $data) { if (3 !== $type) { - $callback($type === self::STDOUT ? self::OUT : self::ERR, $data); + $callback(self::STDOUT === $type ? self::OUT : self::ERR, $data); } elseif (!isset($this->fallbackStatus['signaled'])) { $this->fallbackStatus['exitcode'] = (int) $data; } diff --git a/src/Symfony/Component/Process/Tests/ProcessTest.php b/src/Symfony/Component/Process/Tests/ProcessTest.php index 5a5c3d6a61063..1ad601c715aaf 100644 --- a/src/Symfony/Component/Process/Tests/ProcessTest.php +++ b/src/Symfony/Component/Process/Tests/ProcessTest.php @@ -80,7 +80,7 @@ public function testInvalidCwdOnWindows() // Check that it works fine if the CWD exists $cmd = new Process('echo test', __DIR__); $cmd->run(); - } catch(\Exception $e) { + } catch (\Exception $e) { $this->fail($e); } @@ -353,7 +353,7 @@ public function testCallbackIsExecutedForOutput() $called = false; $p->run(function ($type, $buffer) use (&$called) { - $called = $buffer === 'foo'; + $called = 'foo' === $buffer; }); $this->assertTrue($called, 'The callback should be executed with the output'); @@ -366,7 +366,7 @@ public function testCallbackIsExecutedForOutputWheneverOutputIsDisabled() $called = false; $p->run(function ($type, $buffer) use (&$called) { - $called = $buffer === 'foo'; + $called = 'foo' === $buffer; }); $this->assertTrue($called, 'The callback should be executed with the output'); pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy