ID:               46395
 User updated by:  ebosman at gmail dot com
 Reported By:      ebosman at gmail dot com
 Status:           Open
 Bug Type:         Directory function related
 Operating System: Linux
 PHP Version:      5.2.6
 New Comment:

correction, for top.php it should be (still no difference):

/var/www/bug/top.php /var/www/bug
/var/www/bug/subdir/sub.inc /var/www/bug
(and htmlized)
Warning: require_once(../top1.inc) [function.require-once]: failed to
open stream: No such file or directory in /var/www/bug/subdir/sub.inc on
line 1

Fatal error: require_once() [function.require]: Failed opening required
'../top1.inc' (include_path='.:/usr/share/php:/usr/share/pear') in
/var/www/bug/subdir/sub.inc on line 1

(line difference in the previous comment was because of copy-pasting)


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

[2008-11-24 17:15:22] ebosman at gmail dot com

Same result:

subdir/sub.php:

/var/www/bug/subdir/sub.php /var/www/bug/subdir
/var/www/bug/subdir/sub.inc /var/www/bug/subdir
/var/www/bug/top1.inc /var/www/bug/subdir
/var/www/bug/top2.inc /var/www/bug/subdir

top.php:

Warning: require_once(../top1.inc) [function.require-once]: failed to
open stream: No such file or directory in /var/www/bug/subdir/sub.inc on
line 2

Fatal error: require_once() [function.require]: Failed opening required
'../top1.inc' (include_path='/usr/share/php:/usr/share/pear') in
/var/www/bug/subdir/sub.inc on line 2

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

[2008-11-24 09:52:56] [EMAIL PROTECTED]

Try removing the . from your include_path setting.

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

[2008-10-26 19:32:50] ebosman at gmail dot com

I added 'echo __FILE__," ",getcwd(), "\n";' to each line:

mkdir -p bug/subdir
echo '<?php echo __FILE__," ",getcwd(), "\n"; require_once
"../top1.inc"; ?>' > bug/subdir/sub.inc
echo '<?php echo __FILE__," ",getcwd(), "\n"; require_once "sub.inc";
?>' > bug/subdir/sub.php
echo '<?php echo __FILE__," ",getcwd(), "\n"; require_once
"subdir/sub.inc"; ?>' > bug/top.php
echo '<?php echo __FILE__," ",getcwd(), "\n"; require_once "top2.inc";
?>' > bug/top1.inc
echo '<?php echo __FILE__," ",getcwd(), "\n"; ?>' > bug/top2.inc

The output for subdir/sub.php:

/var/www/bug/subdir/sub.php /var/www/bug/subdir
/var/www/bug/subdir/sub.inc /var/www/bug/subdir
/var/www/bug/top1.inc /var/www/bug/subdir
/var/www/bug/top2.inc /var/www/bug/subdir

and for top.php:

/var/www/bug/top.php /var/www/bug
/var/www/bug/subdir/sub.inc /var/www/bug
(and htmlized:)
Warning: require_once(../top1.inc) [function.require-once]: failed to
open stream: No such file or directory in /var/www/bug/subdir/sub.inc on
line 1

Fatal error: require_once() [function.require]: Failed opening required
'../top1.inc' (include_path='.:/usr/share/php:/usr/share/pear') in
/var/www/bug/subdir/sub.inc on line 1

This would be consistent with the first include method
(relative to the original file.) But in that case including
top2.inc should fail, which it doesn't.

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

[2008-10-26 18:57:32] [EMAIL PROTECTED]

Put 'echo getcwd(), "\n";' to each file before the require line.

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

[2008-10-26 18:15:19] ebosman at gmail dot com

Description:
------------
In the code pasted below:

- top.php fails on subdir/sub.inc including "../top1.inc"
- subdir/sub.php doesn't.

Either every include should be relative to the original php file
(which would be braindead, but consistent.) In that case both
php files should fail (for subdir/sub.php the include of top2.inc
by top1.inc should fail.)

Or (and this is what I expected) include files should be relative
to the file that is including. In which case both should succeed.

Probably the same bug as http://bugs.php.net/bug.php?id=38302 , which
is labeled bogus, so I had to create a new one.

Reproduce code:
---------------
mkdir -p bug/subdir
echo '<?php require_once "../top1.inc" ?>' > bug/subdir/sub.inc
echo '<?php require_once "sub.inc" ?>' > bug/subdir/sub.php
echo '<?php require_once "subdir/sub.inc" ?>' > bug/top.php
echo '<?php require_once "top2.inc" ?>' > bug/top1.inc
touch bug/top2.inc

Expected result:
----------------
Neither top.php nor subdir/sub.php should generate errors (or both
should.)

Actual result:
--------------
Warning: require_once(../top1.inc) [function.require-once]: failed to
open stream: No such file or directory in /var/www/bug/subdir/sub.inc on
line 1

Fatal error: require_once() [function.require]: Failed opening required
'../top1.inc' (include_path='.:/usr/share/php:/usr/share/pear') in
/var/www/bug/subdir/sub.inc on line 1


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


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

Reply via email to