ID:               46260
 Comment by:       miguel-php at cr dot uz
 Reported By:      bugs dot php dot net at callum-macdonald dot com
 Status:           Open
 Bug Type:         Feature/Change Request
 Operating System: Linux
 PHP Version:      5.2.6
 New Comment:

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.


Previous Comments:
------------------------------------------------------------------------

[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.

------------------------------------------------------------------------

[2008-10-09 01:32:07] bugs dot php dot net at callum-macdonald dot com

Description:
------------
See these bugs:
http://bugs.php.net/bug.php?id=38790
http://bugs.php.net/bug.php?id=42516
http://bugs.php.net/bug.php?id=37603

The __FILE__ constant should not, in my opinion, resolve symbolic links
on *nix operating systems. At the very least, there should be an option
to control this behaviour.

Because __FILE__ returns only the symlink resolved path, there is no
way to get the symlink path of the currently included file. If __FILE__
returned the symlinkpath, the resolved path could be retrieved with
realpath(__FILE__).

The opposite is not true. There is no way to go from the resolved path
to the original link path. I realise this is a feature not a bug, but I
believe it is a serious shortcoming and limits the ability of PHP in
symlinked situations.

Reproduce code:
---------------
See http://bugs.php.net/bug.php?id=37603

Expected result:
----------------
__FILE__ should return the symlink path

Actual result:
--------------
__FILE__ returns the resolved path


------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=46260&edit=1

Reply via email to