From: mzajonc at pomona dot edu Operating system: Linux Redhat 7.2 PHP version: 5.0.0RC2 PHP Bug Type: CGI related Bug description: CGI include/require (realpath) mishandles relative paths
Description: ------------ It appears that when running php from the command line relative paths such as require("../include/test.php") do not function the same in php4.2.3 and php5.0.0RC2. Relative paths in php5 are computed relative to the current directory not relative to the script. This causes commands (typically run in crontab) like php -f /www/foo/bar/test.php to break if test.php has require/include statements that are relative. Reproduce code: --------------- The test script (located: /www/www.test.com/test/test.php): <?php echo realpath("../test/test.php") ?> >From command line: $ cd /www $ php -f /www/www.test.com/test/test.php Expected result: ---------------- /www/www.test.com/test/test.php Actual result: -------------- When php4 is used, the output is as expected. When php5 is used, realpath fails and returns FALSE. It appears to consider realpath("../test/test.php") to be "/test/test.php" (given current directory of /www). However, if you do "cd /www/www.test.com/test" and then run the same command, the realpath returns what is expected (since script location is the same as the current directory). -- Edit bug report at http://bugs.php.net/?id=28338&edit=1 -- Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=28338&r=trysnapshot4 Try a CVS snapshot (php5): http://bugs.php.net/fix.php?id=28338&r=trysnapshot5 Fixed in CVS: http://bugs.php.net/fix.php?id=28338&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=28338&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=28338&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=28338&r=needscript Try newer version: http://bugs.php.net/fix.php?id=28338&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=28338&r=support Expected behavior: http://bugs.php.net/fix.php?id=28338&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=28338&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=28338&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=28338&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=28338&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=28338&r=dst IIS Stability: http://bugs.php.net/fix.php?id=28338&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=28338&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=28338&r=float