From 880da01c49a9255f5022ab7e18bca38c18f56370 Mon Sep 17 00:00:00 2001 From: Joseph Bielawski Date: Tue, 8 Jan 2013 13:27:17 +0100 Subject: [PATCH] [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) --- src/Symfony/Component/Process/Process.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Component/Process/Process.php b/src/Symfony/Component/Process/Process.php index 7c6d135534..cf553ee11a 100644 --- a/src/Symfony/Component/Process/Process.php +++ b/src/Symfony/Component/Process/Process.php @@ -53,7 +53,7 @@ class Process } $this->commandline = $commandline; - $this->cwd = null === $cwd ? getcwd() : $cwd; + $this->cwd = $cwd; if (null !== $env) { $this->env = array(); foreach ($env as $key => $value) { @@ -359,6 +359,13 @@ class Process */ public function getWorkingDirectory() { + // This is for BC only + if (null === $this->cwd) { + // getcwd() will return false if any one of the parent directories does not have + // the readable or search mode set, even if the current directory does + return getcwd() ?: null; + } + return $this->cwd; }