Bug #51972 [Com]: PHP 5.3.x bug Require_once don't work with RELATIVE symbolic link

From: Date: Sun, 09 Dec 2012 07:06:23 +0000
Subject: Bug #51972 [Com]: PHP 5.3.x bug Require_once don't work with RELATIVE symbolic link
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-175228@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=51972&edit=1

 ID:                 51972
 Comment by:         p1 at originsystems dot co dot za
 Reported by:        jacques dot moati at happyend dot fr
 Summary:            PHP 5.3.x bug Require_once don't work with RELATIVE
                     symbolic link
 Status:             Feedback
 Type:               Bug
 Package:            *General Issues
 Operating System:   Ubuntu Lucid Lynx
 PHP Version:        5.3.2
 Block user comment: N
 Private report:     N

 New Comment:

I see this problem also.

Assume the following files:
/mylib/css.php
/mylib/needs/supportfile.php

and the contents of css.php are something like as follows:
<?php
require_once('needs/supportfile.php');

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
<?php
include_once('css/css.php');

print css::get();
?>

This fails as the require_once in css.php does not find the needs/supportfile.php file


Previous Comments:
------------------------------------------------------------------------
[2012-03-21 17:01:06] php dot net at doppy dot nl

I'm unable to reproduce this.

tried:
- 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 
code/files.

------------------------------------------------------------------------
[2010-10-17 21:08:36] 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.

------------------------------------------------------------------------
[2010-06-03 13:07:57] sjoerd@php.net

Not enough information was provided for us to be able
to handle this bug. Please re-read the instructions at
http://bugs.php.net/how-to-report.php

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-06-02 11:04:19] jacques dot moati at happyend dot fr

Description:
------------
Hello,

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



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



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


Thread (7 messages)

« previous php.bugs (#175228) next »