php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #47785 get_included_files resolves symlinks
Submitted: 2009-03-26 04:04 UTC Modified: 2013-11-02 16:07 UTC
Votes:5
Avg. Score:4.8 ± 0.4
Reproduced:4 of 4 (100.0%)
Same Version:2 (50.0%)
Same OS:3 (75.0%)
From: andre at webkr dot de Assigned: krakjoe (profile)
Status: Not a bug Package: *General Issues
PHP Version: 5.2.9 OS: Linux
Private report: No CVE-ID: None
 [2009-03-26 04:04 UTC] andre at webkr dot de
Description:
------------
When a symlink is included/required, get_included_files shows the target of the symlink. Together with Bug #46260 this makes it completely impossible to determine how the file was really called when it was included.

Reproduce code:
---------------
include('path_to/a_symlink.php');
var_dump(get_included_files());

Expected result:
----------------
An array containing a string "[...]/path_to/a_symlink.php".

Actual result:
--------------
An array containing a string "[...]/some_file.php".

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-03-29 02:52 UTC] andre at webkr dot de
It's even worse:
When an included file includes another file using a relative path, that is looked up in the target directory of the symlink!

It should be relative to the path where the symlink resides. The only access types that should treat the symlink in a special way are unlink (it should remove the symlink, not the target file) and chmod (it should do nothing). All other access types (especially the read involved here) should see the symlink as if it were a file with the content and attributes of the target file.
 [2013-11-02 15:39 UTC] krakjoe@php.net
-Status: Open +Status: Closed -Package: Feature/Change Request +Package: *General Issues -Assigned To: +Assigned To: krakjoe
 [2013-11-02 15:39 UTC] krakjoe@php.net
Symlinks are resolved to their full paths because it's the only sensible thing to do.

If your application requires the relative path, it should be no problem to discover it, being that if the path of the application is relevant information then you should have it in a variable/constant somewhere.

This is a non-issue.
 [2013-11-02 16:07 UTC] pajoye@php.net
-Status: Closed +Status: Not a bug
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon Apr 29 11:01:32 2024 UTC