#49456 [NEW]: Script current working directory converted to real path cause require() errors
From: michele dot manzato at gmail dot com
Operating system: Ubuntu/Hardy
PHP version: 5.2.11RC1
PHP Bug Type: Scripting Engine problem
Bug description: Script current working directory converted to real path cause require() errors
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 bug report at http://bugs.php.net/?id=49456&edit=1
--
Try a snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=49456&r=trysnapshot52
Try a snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=49456&r=trysnapshot53
Try a snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=49456&r=trysnapshot60
Fixed in SVN: http://bugs.php.net/fix.php?id=49456&r=fixed
Fixed in SVN and need be documented: http://bugs.php.net/fix.php?id=49456&r=needdocs
Fixed in release: http://bugs.php.net/fix.php?id=49456&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=49456&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=49456&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=49456&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=49456&r=support
Expected behavior: http://bugs.php.net/fix.php?id=49456&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=49456&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=49456&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=49456&r=globals
PHP 4 support discontinued: http://bugs.php.net/fix.php?id=49456&r=php4
Daylight Savings: http://bugs.php.net/fix.php?id=49456&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=49456&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=49456&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=49456&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=49456&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=49456&r=mysqlcfg
Thread (2 messages)
- michele dot manzato at gmail dot com