Skip to content

Commit f9ed2bc

Browse files
committed
merged branch stloyd/bugfix/process_cwd (PR #6620)
This PR was merged into the 2.0 branch. Commits ------- 880da01 [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) Discussion ---------- [2.0][Process] In edge cases `getcwd()` can return `false` Bug fix: yes Feature addition: no BC break: no Symfony2 tests pass: yes 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). --------------------------------------------------------------------------- by stloyd at 2013-01-08T12:43:40Z I guess that this could be related to #6496, as error code `267` at Windows means: [`ERROR_DIRECTORY - The directory name is invalid.`](http://msdn.microsoft.com/en-us/library/ms681382%28v=vs.85%29.aspx#error_directory) --------------------------------------------------------------------------- by Seldaek at 2013-01-08T12:57:38Z If null already uses the current working directory, what's the point of calling getcwd() at all? --------------------------------------------------------------------------- by stloyd at 2013-01-08T13:03:06Z @Seldaek TBH. I don't have idea =) It seems that it's there _from the beginning_, but yeah, I was a bit confused by usage of it too... --------------------------------------------------------------------------- by fabpot at 2013-01-09T08:13:24Z What about removing the code altogether? --------------------------------------------------------------------------- by stloyd at 2013-01-09T08:22:55Z @fabpot I'm ok with that, just not sure it will not be an BC break... --------------------------------------------------------------------------- by Seldaek at 2013-01-09T08:24:57Z php.net says `or NULL if you want to use the default value (the working dir of the current PHP process)` which sounds like getcwd() to me. --------------------------------------------------------------------------- by Seldaek at 2013-01-09T08:26:32Z For full BC though, `getWorkingDirectory` should `return $this->cwd ?: getcwd();` Then at least if that call fails the whole process isn't failing. I don't see why anyone would use that getter though. --------------------------------------------------------------------------- by stloyd at 2013-01-10T12:43:59Z @fabpot @Seldaek What do you think about this now? --------------------------------------------------------------------------- by Seldaek at 2013-01-10T12:58:39Z :+1:
2 parents 835c1b8 + 880da01 commit f9ed2bc

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)
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