Edit report at http://bugs.php.net/bug.php?id=46260&edit=1
ID: 46260 Comment by: rix at mindginative dot com Reported by: bugs dot php dot net at callum-macdonald dot com Summary: __FILE__ should not resolve symlink paths Status: Open Type: Feature/Change Request Package: Feature/Change Request Operating System: Linux PHP Version: 5.2.6 Block user comment: N New Comment: +1 for this. I encountered this issue today and was hoping that there's a better way not to resolve symlink in __FILE__. As suggested above, perhaps __FILE_LINK__ that either return the symlink path or false if none. Previous Comments: ------------------------------------------------------------------------ [2009-09-26 21:01:15] miguel-php at cr dot uz Another vote for this. The current implementation does not seem like the proper way to treat symlinks, and it makes sharing included files between directories very difficult. I understand that changing this now has the potential to cause breakage in scripts that depend on the current behaviour. But there really does need to be a way for a file to find its own effective location. ------------------------------------------------------------------------ [2009-09-22 06:42:10] glideraerobatics at hotmail dot com I have the same problem with PHP. I have a slave site that shares most (but not all!) code with a master site using symlinks. The code consists of CLI scripts, web pages, and includes (one of which is a common include for setting up the include_path and error handling). It is critical that this include_path refers to paths in the slave site even though the real common include resides in the master site. I can't achieve this using __FILE__ unfortunately due to the symlink resolution problem. It would be nice to have an alternative to __FILE__, perhaps __LINK__, with unresolved symlinks. Please PHP developers add this!!! PHP needs it so much and it must be a very simple thing to add. In the mean time, I've created a function in the common include that jumps though hoops in order to set the include_path correctly by using argv[0] in CLI scripts (and traversing up until a htdocs dir is found) or else $_SERVER['DOCUMENT_ROOT'] in web scripts. It's horrible, but the only solution I've found so far. ------------------------------------------------------------------------ [2009-07-02 16:43:32] raphael dot roulet at univ-st-etienne dot fr If there is no security issue, Why don't PHP make life easier ? ------------------------------------------------------------------------ [2009-01-31 23:12:49] bugs dot php dot net at callum-macdonald dot com $_SERVER['PHP_SELF'] only relates to the main script, not the currently included file. It's useful, but a completely separate issue. There is, as far as I can see, no way to get the non symlink resolved path of the currently included file. ------------------------------------------------------------------------ [2009-01-31 22:54:44] luke_phpbugs at dashjr dot org $_SERVER["PHP_SELF"] helps a little. ------------------------------------------------------------------------ The remainder of the comments for this report are too long. To view the rest of the comments, please view the bug report online at http://bugs.php.net/bug.php?id=46260 -- Edit this bug report at http://bugs.php.net/bug.php?id=46260&edit=1