|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #51972 PHP 5.3.x bug Require_once don't work with RELATIVE symbolic link
Submitted: 2010-06-02 11:04 UTC Modified: 2013-02-18 00:34 UTC
Avg. Score:4.6 ± 0.7
Reproduced:13 of 14 (92.9%)
Same Version:7 (53.8%)
Same OS:2 (15.4%)
From: jacques dot moati at happyend dot fr Assigned:
Status: No Feedback Package: *General Issues
PHP Version: 5.3.2 OS: Ubuntu Lucid Lynx
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2010-06-02 11:04 UTC] jacques dot moati at happyend dot fr

This bug is present into all 5.3 php version.
I test it in the ubuntu package, php 5.3 stable and snap version with --disable-all for ./config compilation.

When you include a file in a relative (eg ../) symbolic link directory, PHP don't include it and do a FATAL error.

files_existes and is_readable return true ...
If the symbolic link of the diectory is absolute, the include work correctly ...


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2010-06-03 13:07 UTC]
-Status: Open +Status: Feedback
 [2010-06-03 13:07 UTC]
Not enough information was provided for us to be able
to handle this bug. Please re-read the instructions at

If you can provide more information, feel free to add it
to this bug and change the status back to "Open".

Thank you for your interest in PHP.

I could not reproduce the problem.
 [2010-10-17 21:08 UTC] federico at bernardin dot it
I found the same problem.
If you use a require_once with a relative path and then you use a require_once with absolute path but to the same file, php include the file twice. I try this bug in version 5.2.x and the problem there isn't.
 [2012-03-21 17:01 UTC] php dot net at doppy dot nl
I'm unable to reproduce this.

- 2 require_once: 1 relative, 1 absolute
- 2 require_once: 1 relative, 1 absolute with a symlink-dir somewhere in there.

Also, when including/requiring a file with a path that contains a symlink 
somewhere, PHP will resolve the symlink and use the actual path of the location 
(like using realpath).
You can see this when you use the function get_included_files.

I would love to see some code that actually reproduces this. Please post the 
 [2012-12-09 07:06 UTC] p1 at originsystems dot co dot za
I see this problem also.

Assume the following files:

and the contents of css.php are something like as follows:

class css {
 static function get() {
   return "#col { color: red; }";

Then assume an application that uses the css.php library
cd /anApplication
ln -s /mylib css

then create the file /anApplication/test.php with the following contents

print css::get();

This fails as the require_once in css.php does not find the needs/supportfile.php file
 [2012-12-09 08:15 UTC] p1 at originsystems dot co dot za
Hello again,

my apologies - my comment above is WRONG

The reason for the problem is that I am using samba so what I did in my situation was

1. download a zip file of  the library I am testing in windows
2. extract the zip file over the samba folder
3. referenced the extracted files directly from the linux server presenting the samba folder

To remove the problem I downloaded the equivalent tar version to the linux server and extracted it on the linux server directly - then the require_once worked 100%

So although I cannot prove it - as no error was thrown, the require_once simply didn't work - it appears that the problem was to do with dos/linux file differences. Regardless, though I hope this is useful to someone as it was a nasty problem to track down due to the lack of errors.

apologies for the red herring
 [2013-02-18 00:34 UTC] php-bugs at lists dot php dot net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Open". Thank you.
PHP Copyright © 2001-2022 The PHP Group
All rights reserved.
Last updated: Tue Jan 18 08:03:18 2022 UTC