-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[2.0][Process] In edge cases getcwd()
can return false
#6620
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
I guess that this could be related to #6496, as error code |
If null already uses the current working directory, what's the point of calling getcwd() at all? |
@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... |
What about removing the code altogether? |
@fabpot I'm ok with that, just not sure it will not be an BC break... |
php.net says |
For full BC though, |
…n()` should get `null` to use default value (the working dir of the current PHP process)
👍 |
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:
This PR was merged into the 2.0 branch. Commits ------- 179cd58 [Process] Fix regression introduced in #6620 / 880da01, fixes #7082 Discussion ---------- [Process][2.0] getcwd failure fix Fix regression introduced in #6620 Fixes #7082 For reference, here is the current behavior I saw: PHP 5.4.11, windows: ``` 5.4.11\php.exe -r "chdir('c:\\'); var_dump(getcwd()); $p = proc_open('pwd', [['pipe', 'r'], ['pipe', 'w'], ['pipe', 'w']], $pipes, null); var_dump(stream_get_contents($pipes[1]));" string(3) "C:\\" string(14) "/c/Users/seld\n" ``` (I use pwd which is a unix util so it dumps a funny path, but don't look at that) PHP 5.5alpha4, windows (seems fixed): ``` 5.5.0a4\php.exe -r "chdir('c:\\'); var_dump(getcwd()); $p = proc_open('pwd', [['pipe', 'r'], ['pipe', 'w'], ['pipe', 'w']], $pipes, null); var_dump(stream_get_contents($pipes[1]));" string(3) "C:\" string(3) "/c\n" ``` PHP 5.3.10, ubuntu: ``` php -r "chdir('/'); var_dump(getcwd()); \$p = proc_open('pwd', array(array('pipe', 'r'), array('p ipe', 'w'), array('pipe', 'w')), \$pipes, null); var_dump(stream_get_contents(\$pipes[1]));" string(1) "/" string(2) "/\n" ``` Since the permission issue that #6620 originally was fixing is most likely not gonna happen on windows, this seems like a safe enough compromise. Ideally a check for PHP<5.5 should be introduced, but I would like to be sure it's been fixed and is not just a lucky coincidence (/cc @pierrejoye) I would recommend merging fast and maybe adding the version check later, since it breaks composer create-project on windows. The workaround being: cd in the dir and run `composer install` again to finalize the project setup. --------------------------------------------------------------------------- by vicb at 2013-02-17T20:12:17Z Thanks @Seldaek ! Would you mind creating an issue for the version check so that it doesn't get lost ? --------------------------------------------------------------------------- by Seldaek at 2013-02-18T10:43:56Z @vicb done. --------------------------------------------------------------------------- by vicb at 2013-02-18T11:45:16Z thanks !
* 2.2: (22 commits) [Process] Fix regression introduced in #6620 / 880da01, fixes #7082 [HttpKernel] added a unit for the previous commit (closes #7025) [HttpFoundation] fixed, overwritten CONTENT_TYPE [BrowserKit] fixed test added in the previous merge (refs #7059) [FrameworkBundle] tweaked reference dumper command (see #7093) Remove unnecessary comment and change test name [Config] tweaked dumper to indent multi-line info [HttpKernel] added some tests for previous merge Fix REMOTE_ADDR for cached subrequests [FrameworkBundle] CSRF should be on by default [WebProfilerBundle] removed dependency on FrameworkBundle (closes #6949) [HttpKernel] added error display suppression when using the ErrorHandler (if not, errors are displayed twice, refs #6254) [HttpFoundation] tweaked previous merge [HttpFoundation] Added getter for httpMethodParameterOverride state Create validators.lv.xlf [Process] Warn user with a useful message when tmpfile() failed [BrowserKit] added a test to make sure HTTP authentication is preserved when submitting a form Remove array type hint from GetResponseForControllerResultEvent::setControllerResult() bumped Symfony version to 2.2.0-DEV Revert "merged branch povilas/issue_6101 (PR #6708)" ...
* 2.2: (22 commits) [Process] Fix regression introduced in symfony#6620 / 880da01, fixes symfony#7082 [HttpKernel] added a unit for the previous commit (closes symfony#7025) [HttpFoundation] fixed, overwritten CONTENT_TYPE [BrowserKit] fixed test added in the previous merge (refs symfony#7059) [FrameworkBundle] tweaked reference dumper command (see symfony#7093) Remove unnecessary comment and change test name [Config] tweaked dumper to indent multi-line info [HttpKernel] added some tests for previous merge Fix REMOTE_ADDR for cached subrequests [FrameworkBundle] CSRF should be on by default [WebProfilerBundle] removed dependency on FrameworkBundle (closes symfony#6949) [HttpKernel] added error display suppression when using the ErrorHandler (if not, errors are displayed twice, refs symfony#6254) [HttpFoundation] tweaked previous merge [HttpFoundation] Added getter for httpMethodParameterOverride state Create validators.lv.xlf [Process] Warn user with a useful message when tmpfile() failed [BrowserKit] added a test to make sure HTTP authentication is preserved when submitting a form Remove array type hint from GetResponseForControllerResultEvent::setControllerResult() bumped Symfony version to 2.2.0-DEV Revert "merged branch povilas/issue_6101 (PR symfony#6708)" ...
Bug fix: yes
Feature addition: no
BC break: no
Symfony2 tests pass: yes
In edge cases
getcwd()
can returnfalse
, thenproc_open()
should getnull
to use default value (the working dir of the current PHP process).