#49456 [Opn->Bgs]: Script current working directory converted to real path cause require() errors
| From: | sjoerd@php.net | Date: | Thu, 03 Sep 2009 14:45:49 +0000 |
| Subject: | #49456 [Opn->Bgs]: Script current working directory converted to real path cause require() errors | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-141917@lists.php.net to get a copy of this message | ||
ID: 49456
Updated by: sjoerd@php.net
Reported By: michele dot manzato at gmail dot com
-Status: Open
+Status: Bogus
Bug Type: Scripting Engine problem
Operating System: Ubuntu/Hardy
PHP Version: 5.2.11RC1
New Comment:
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to
report
a bug at http://bugs.php.net/how-to-report.php
Note that this behavior is the same as in a shell:
cd b/c
ls ..
It shows the contents of /tmp, not the contents of /tmp/b. This works
as it should.
Previous Comments:
------------------------------------------------------------------------
[2009-09-03 14:36:40] michele dot manzato at gmail dot com
Description:
------------
PHP script current working directory being converted to the real path
cause error in relative files inclusion (see also bug #46814).
As one can see in the reproduce code the script's getcwd() says
'/tmp/a' although the script was run from '/tmp/b/c'. As a result the
require() instruction fails because it can't find any '/inc.php'.
'/tmp/b/inc.php' would have been found if the original symlinked path
was preserved.
Reproduce code:
---------------
~$ cd /tmp
/tmp$ mkdir a
/tmp$ mkdir b
/tmp$ echo '<?php echo getcwd(); require "../inc.php";?>' > a/test.php
/tmp$ echo '<?php echo "ok\n";?>' > b/inc.php
/tmp$ ln -s /tmp/a b/c
/tmp$ cd b/c/
/tmp/b/c$ php -f test.php
Expected result:
----------------
ok
Actual result:
--------------
/tmp/a
Warning: require(../inc.php): failed to open stream: No such file or
directory in /tmp/a/test.php on line 1
Fatal error: require(): Failed opening required '../inc.php'
(include_path='.:/usr/share/php:/usr/share/pear') in /tmp/a/test.php on
line 1
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=49456&edit=1