Req #42516 [Com]: __FILE__ resolves symlinks
| From: | michael at zedeler dot dk | Date: | Sun, 07 Jan 2024 18:02:14 +0000 |
| Subject: | Req #42516 [Com]: __FILE__ resolves symlinks | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-246187@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=42516&edit=1
ID: 42516
Comment by: michael at zedeler dot dk
Reported by: michael at zedeler dot dk
Summary: __FILE__ resolves symlinks
Status: Not a bug
Type: Feature/Change Request
Package: Scripting Engine problem
Operating System: Linux
PHP Version: 4.4.7
Block user comment: N
Private report: N
New Comment:
Every time I am asked if I can take on PHP assignments, I remember this ticket and turn them down. I
could elaborate, but then I would probably be in violation of the community guidelines.
Previous Comments:
------------------------------------------------------------------------
[2024-01-05 06:56:26] gerardreches at gmail dot com
I am using WordPress and instead of copying my plugins files for each WordPress installation, I am
using them through symlinks.
Some of these plugins require the unresolved path for WordPress to be able to enqueue styles and
scripts. These plugins may either be used as a plugin or a library as part of another plugin, which
makes alternatives to retrieve the path unusable.
17 years, multiple requests, and nothing has been done yet about this. We are not even asking for
the __FILE__ and __DIR__ behaviour to be changed, but to get a new pair of constants that return the
unresolved path.
------------------------------------------------------------------------
[2021-05-26 11:55:38] zjz at zjz dot name
Here's a scenario where symlinks-unresolved path constants are helpful:
Suppose there are two sub-projects d1 and d2, and I want to reuse some file of d1 in d2, then I
apply soft link to it:
/<path-of-d1>/f1.php
/<path-of-d1>/f2.php
/<path-of-d2>/f1.php --> /<path-of-d1>/f1.php (soft link)
/<path-of-d2>/f2.php
The content of /<path-of-d1>/f1.php contains the following the include directive:
include __DIR__ . '/f2.php';
The included path is always resolved as /<path-of-d1>/f2.php, it would be unfortunate if in
fact we want the /<path-of-d2>/f2.php to be included. I think introducing a new pair magical
constants corresponding to __FILE__ and __DIR__ is desirable.
Thank you.
------------------------------------------------------------------------
[2018-12-03 00:47:15] pmugane at gmail dot com
Really concerned about how this whole process has been ignored.
If __FILE__ is intended to resolve symlinks by design then provide a way to get the directory of the
symlink - it's really not that hard.
Seriously, it's been over a decade and this is still unresolved.
------------------------------------------------------------------------
[2013-01-24 15:21:52] michael at zedeler dot dk
I agree that this isn't a bug. I filed it as a change/feature request. Please revert.
------------------------------------------------------------------------
[2013-01-23 19:01:16] pajoye@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to
report
a bug at http://bugs.php.net/how-to-report.php
It is required by require_once and include_once, along other things (realpath
cache). It always been like that.
------------------------------------------------------------------------
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
https://bugs.php.net/bug.php?id=42516
--
Edit this bug report at https://bugs.php.net/bug.php?id=42516&edit=1