php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #59757 relative paths on includes incorrect
Submitted: 2011-05-08 13:32 UTC Modified: 2011-05-18 04:38 UTC
From: elrah at polyptych dot com Assigned:
Status: Closed Package: APC (PECL)
PHP Version: 5.3.5 OS: CentOS 5.6
Private report: No CVE-ID: None
 [2011-05-08 13:32 UTC] elrah at polyptych dot com
Description:
------------
PHP has the following behavior:

include('./blah.php');
is equivalent to:
include(getcwd().'/blah.php');

and

include('blah.php');
is equivalent to:
include(dirname(__FILE__).'/blah.php');

After installing APC 3.1.8, both cases are now treated as "getcwd()" by APC.  This causes any code that has nested includes that uses the second form of relative path to break.

The first time a page is loaded, it works, but the second time will produce an error.

Additional information:
* I suspect this problem might be related to the fix for bug 20529.
* I'm actually using PHP 5.3.6, but it's not listed above in the select box.
* The specific build of APC I'm using is through the following RPM: php-pecl-apc-3.1.8-1.el5.remi
* I also compiled APC directly from PECL, and was still able to reproduce the problem

Reproduce code:
---------------
test.php:
<?php
include(dirname(__FILE__).'/subdir/blah.php');
?>

subdir/blah.php:
<?php
include("foo.php");
?>

subdir/foo.php:
<?php
echo 'success';
?>

Expected result:
----------------
to echo the word "success" on the first and subsequent executions when accessing through a web browser

Actual result:
--------------
1. It always works from the command line
2. It works on the first run in a browser (before it is cached by APC)
3. On subsequent runs, the following error is displayed:

Warning: include(foo.php): failed to open stream: No such file or directory in on line 2 Warning: include(): Failed opening 'foo.php' for inclusion (include_path='.:/var/www/test_libs/users_include') in on line 2 

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2011-05-08 14:03 UTC] elrah at polyptych dot com
It may also be the same problem as bug 22694.  I am also seeing the corruption of the include path in the apache error_log.
 [2011-05-08 14:09 UTC] rasmus@php.net
Do you have the Suhosin extension enabled? If so, disable it 
and try again.
 [2011-05-08 14:50 UTC] elrah at polyptych dot com
I don't see any reference to suhosin in php.ini, /
etc/php.d/*, or phpinfo() so I don't believe it is 
installed.
 [2011-05-08 17:07 UTC] jasonwyz98 at gmail dot com
Hi

Yep the latest v3.1.8 breaks include.

BTW: I have suhosin disabled, same result.

Please fix asap.

Thanks
Jason
 [2011-05-11 18:54 UTC] tom at bangbros dot com
I am the original reporter of <a href="http://pecl.php.net/bugs/22694">bug report 22694</a>.

We're seeing the corruption with the suhosin PHP source patch... not to be confused with the suhosin extension.  (My inclination is to say this bug is not suhosin related).

It may be helpful to state that the affected application is a PHP framework site.
 [2011-05-13 16:35 UTC] gopalv@php.net
Please test the code off apc-trunk

http://svn.php.net/repository/pecl/apc/trunk/
 [2011-05-18 04:37 UTC] elrah at polyptych dot com
Fixed in 3.1.9.  Thank you!
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri May 03 18:01:34 2024 UTC