8000 [Process] In edge cases `getcwd()` can return `false`, then `proc_ope… · symfony/symfony@880da01 · GitHub
[go: up one dir, main page]

Skip to content

Commit 880da01

Browse files
committed
[Process] In edge cases getcwd() can return false, then proc_open() should get null to use default value (the working dir of the current PHP process)
1 parent 835c1b8 commit 880da01

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/Symfony/Component/Process/Process.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public function __construct($commandline, $cwd = null, array $env = null, $stdin
5353
}
5454

5555
$this->commandline = $commandline;
56-
$this->cwd = null === $cwd ? getcwd() : $cwd;
56+
$this->cwd = $cwd;
5757
if (null !== $env) {
5858
$this->env = array();
5959
foreach ($env as $key => $value) {
@@ -359,6 +359,13 @@ public function setTimeout($timeout)
359359
*/
360360
public function getWorkingDirectory()
361361
{
362+
// This is for BC only
363+
if (null === $this->cwd) {
364+
// getcwd() will return false if any one of the parent directories does not have
365+
// the readable or search mode set, even if the current directory does
366+
return getcwd() ?: null;
367+
}
368+
362369
return $this->cwd;
363370
}
364371

0 commit comments

Comments
 (0)
0