ID:               46814
 Comment by:       php at degoulet dot net
 Reported By:      dennis dot birkholz at nexxes dot net
 Status:           Open
 Bug Type:         Scripting Engine problem
 Operating System: Gentoo/Linux
 PHP Version:      5.2.8
 New Comment:

I don't realy understand your problem ?!
[r...@pix sdv]# ls -alR
.:
total 16
drwxr-xr-x  4 root     root    4096 Dec 17 17:44 .
drwxrwxrwx  3 via      ftponly 4096 Dec 17 17:44 ..
drwxr-xr-x  2 root     root    4096 Dec 17 17:45 docs
drwxr-xr-x  2 root     root    4096 Dec 17 17:46 test1
lrwxrwxrwx  1 root     root       5 Dec 17 17:44 test2 -> test1

./docs:
total 12
drwxr-xr-x  2 root root 4096 Dec 17 17:45 .
drwxr-xr-x  4 root root 4096 Dec 17 17:44 ..
-rw-r--r--  1 root root   24 Dec 17 17:45 docs.inc.php

./test1:
total 12
drwxr-xr-x  2 root root 4096 Dec 17 17:46 .
drwxr-xr-x  4 root root 4096 Dec 17 17:44 ..
-rw-r--r--  1 root root   50 Dec 17 17:46 index.php

[r...@pix sdv]# cat test1/index.php 
<?php
include("../docs/docs.inc.php");
echo "ok\n";
?>
[r...@pix sdv]# cat docs/docs.inc.php 
<?php
echo "docs\n";
?>

No problem when i try this with apache :
http://www.xxxx.com/sdv/test1/index.php
http://www.xxxx.com/sdv/test2/index.php
==> same output : docs ok 

if you try this in command line.
3 cases :
- pwd= test1 : php index.php => output docs ok
- pwd= test2 : php index.php => output docs ok
- pwd= anywhere else : php ./test1/index.php : include(): Unable to
access ../docs/docs.inc.php which is quite normal
the include path is relative to the current directory where php is
executed not relative to the php script which is executed ...

isn't it ?


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

[2008-12-17 22:35:25] dennis dot birkholz at nexxes dot net

This IS a bug: in Linux (and Unix like systems) beeing in a symlinked
directory should behave exactly like beeing in a directory with the same
content.

To use my example: If I use a shell and change to the folder
/htdocs/test2 (which is a symlink to /test1), ls ../docs/docs.inc.php
will show me the file "/htdocs/docs/docs.inc.php" and NOT
"/docs/docs.inc.php".

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

[2008-12-17 16:53:29] php at degoulet dot net

quite normal : not a bug

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

[2008-12-09 18:17:42] dennis dot birkholz at nexxes dot net

Description:
------------
include statement seems to resolve the current working directory other
than the rest of php so if I am in a symlinked directory an try to
include a file using a relative path (containing ../), the include fails
because the original path of the script is used to resolve the relative
include and not the path the script is invoked from.

Reproduce code:
---------------
Asume the following files/directory structure:
Directory /test1
Directory /htdocs
Directory /htdocs/docs
Symlink /htdocs/test2 -> /test1
File /test1/index.php
File /htdocs/docs/docs.inc.php

DocumentRoot is /htdocs

File-Contents of /test1/index.php
<?php
  include("../docs/docs.inc.php");
//  ... other code
?>

Expected result:
----------------
No error, output generated by code after the include

Actual result:
--------------
An error: failed to open stream: No such file or directory
(/test1/index.php:2)


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


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

Reply via email to