php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #30811 virtual() causes relative paths in require() to break
Submitted: 2004-11-17 07:30 UTC Modified: 2004-11-17 18:28 UTC
From: cantrell at pobox dot com Assigned:
Status: Not a bug Package: Apache related
PHP Version: 4.3.9 OS: OS X, Linux
Private report: No CVE-ID: None
 [2004-11-17 07:30 UTC] cantrell at pobox dot com
Description:
------------
When virtual() calls another page that contains 
require('./xyz'), the require() call breaks.  But it 
works with require('xyz'), which smells really bad, and 
makes me think this is a bug and not just me missing 
something.

Posted this to php-general, but got no feedback.

Reproduced on OS X 10.3.6 + Apache 1.3.29 + PHP/4.3.4, 
and on Debian + Apache 1.3.31 + PHP/4.3.9-1.

Reproduce code:
---------------
------ foo.php ------
This is foo.
<?php virtual('subdir/bar.php'); ?>

------ foo.shtml (my "control group") ------
This is foo.
<!--#include virtual="subdir/bar.php"-->

------ subdir/bar.php ------
This is bar.
<?php require('./baz.php'); ?>

------ subdir/baz.php ------
This is baz.


Expected result:
----------------
This is foo.
This is bar.
This is baz.

[Note: foo.shtml correctly produces this output; foo.php 
should in theory work identically, but does not.]

Actual result:
--------------
This is foo.
This is bar.
Warning: main(./baz.php): failed to open stream: No such 
file or directory in /blah/blah/subdir/bar.php on line 2

Fatal error: main(): Failed opening required './baz.php' 
(include_path='.:/usr/local/lib/php') in /blah/blah/
subdir/bar.php on line 2


Oddly, it works if bar.php says require('baz.php') 
instead of require('./baz.php').

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-11-17 17:06 UTC] tony2001@php.net
Sorry, but your problem does not imply a bug in PHP itself.  For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system is not the
appropriate forum for asking support questions. 

Thank you for your interest in PHP.

Your code is similar to:
<? require('./baz.php'); ?>
Obviously baz.php is not in current directory of foo.php.
 [2004-11-17 18:28 UTC] cantrell at pobox dot com
Um, I beg your pardon, but this is not a support 
question.  This behavior is contradictory to the docs, 
and I'm pretty sure it's a bug.

Please read my post a little more carefully.  Note that 
I am not asking for help!

The docs for virtual() say that it works with an Apache 
subquest.  If that were the case, it would work just 
like SSI: the output of bar.php (which works *just fine* 
when called directly) would be inserted into foo.php 
where the virtual() call is.

That's what the docs imply.  It's not what happens.

When PHP doesn't behave as documented, I think it's fair 
to consider that a bug.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun May 05 15:01:33 2024 UTC