From: mmayer at blastwave dot org Operating system: Solaris 9 PHP version: 4.4.0 PHP Bug Type: *Directory/Filesystem functions Bug description: Problems with __FILE__ and realpath()
Description: ------------ This issue seems to be related to bug #27823, but broader in scope. Using __FILE__ or realpath() on Solaris 9 SPARC (don't know about x86) doesn't work as expected if the scripts are located in a user's home-directory (~username/public_html) and the URL looks like http://my.example.com/~user/testscript.php. (Don't know if the '~' is actually causing the problem or if it's something else in this scenario). Note that I *do* get the expected results from these scripts if I copy them to /opt/csw/apache2/share/htdocs/file_bug (i.e. underneath my web-server's doc-root) and access them through a URL like http://my.example.com/file_bug/<scriptname>. In the failure case, __FILE__ returns './<filename>' instead of the full path if it is used in an included file. realpath() returns an empty string instead of the actual path even though the file in question exists and the permissions are correct. (Regardless of whether realpath is used in an included file or directly.) Reproduce code: --------------- === file.php: === <?php print __FILE__; print "<p>"; require("file2.php"); ?> === file2.php: === <?php print __FILE__; ?> === realpath.php: === <?php print("realpath: '".realpath('realpath/test.txt')."'\n"); ?> Expected result: ---------------- file.php should print: /home/markus/public_html/file_bug/file.php /home/markus/public_html/file_bug/file2.php realpath.php should print: realpath: '/home/markus/public_html/file_bug/realpath/test.txt' Actual result: -------------- file.php prints: /home/markus/public_html/file_bug/file.php ./file2.php realpath.php prints: realpath: '' This is the directory layout (just to show that it's not a permission problem): total 14 drwxr-xr-x 3 markus staff 512 Sep 19 09:10 . drwxr-xr-x 11 markus staff 1536 Sep 15 11:07 .. -rw-r--r-- 1 markus staff 60 Sep 14 13:41 file.php -rw-r--r-- 1 markus staff 25 Sep 14 13:41 file2.php drwxr-xr-x 2 markus staff 512 Sep 19 09:07 realpath -rw-r--r-- 1 markus staff 67 Sep 19 09:08 realpath.php ./realpath: total 6 drwxr-xr-x 2 markus staff 512 Sep 19 09:07 . drwxr-xr-x 3 markus staff 512 Sep 19 09:10 .. -rw-r--r-- 1 markus staff 5 Sep 19 09:07 test.txt -- Edit bug report at http://bugs.php.net/?id=34552&edit=1 -- Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=34552&r=trysnapshot4 Try a CVS snapshot (php5.0): http://bugs.php.net/fix.php?id=34552&r=trysnapshot50 Try a CVS snapshot (php5.1): http://bugs.php.net/fix.php?id=34552&r=trysnapshot51 Fixed in CVS: http://bugs.php.net/fix.php?id=34552&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=34552&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=34552&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=34552&r=needscript Try newer version: http://bugs.php.net/fix.php?id=34552&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=34552&r=support Expected behavior: http://bugs.php.net/fix.php?id=34552&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=34552&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=34552&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=34552&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=34552&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=34552&r=dst IIS Stability: http://bugs.php.net/fix.php?id=34552&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=34552&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=34552&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=34552&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=34552&r=mysqlcfg