From: phpbugz at x0rz dot com
Operating system: linux kernel 2.4.27 w/debian 3.1
PHP version: 5.2.0
PHP Bug Type: Apache2 related
Bug description: intermittent include failure under symlinked virtual hosts
Description:
------------
the *first* include will fail intermittently if apache2 virtual host is
pointing to a symlinked DocumentRoot.
problem is not easily reproducable and would occur perhaps 1 in 100 times,
usually disappearing on refresh.
this issue has gone away since reconfiguring the apache virtualhost's
DocumentRoot to point to an absolute path instead of a symlinked one. a
resolution was also found by setting an absolute path for the very first
include within a script.
Reproduce code:
---------------
<?
set_include_path($_SERVER['DOCUMENT_ROOT']);
include('foo_include.php');
include('bar_include.php');
?>
Filesystem :
/home/www -> /var/www
Apache :
<VirtualHost>
DocumentRoot /home/www
</VirtualHost>
Expected result:
----------------
Occasionally observe the following :
*Warning*: include(some_include.php) [function.include]: failed to open
stream: No such file or directory in *foo_include.php* on line *blah*
*Fatal error*: Call to undefined function foo_function() in *bar_include*
on line *blah*
------------
** noting that the first include fails but the second is ok.
** the include_path shown with this error will also point to the symlink
path (/home/www in the 'reproduce code' example), not the symlink target.
Actual result:
--------------
code was added to dump the SERVER variables on include failure, keeping in
mind the filesystem path is actually /var/www :
*Warning*: include(required/connect.php) [function.include]: failed to
open stream: No such file or directory in
*/var/www/moa/XXX/includes/required_includes.php* on line *7*
*Warning*: include() [function.include]: Failed opening
'required/connect.php' for inclusion (include_path='/home/www/moa/XXX/')
in */var/www/moa/XXX/includes/required_includes.php* on line *7*
array(34) { ["nokeepalive"]=> string(1) "1" ["ssl-unclean-shutdown"]=>
string(1) "1" ["downgrade-1_0"]=> string(1) "1" ["force-response-1_0"]=>
string(1) "1" ["HTTP_ACCEPT"]=> string(87) "image/gif, image/x-xbitmap,
image/jpeg, image/pjpeg, application/x-shockwave-flash, */*"
["HTTP_REFERER"]=> string(40) "http://moa.XXX.com/members_index.php"
["HTTP_ACCEPT_LANGUAGE"]=> string(5) "en-us" ["HTTP_UA_CPU"]=> string(3)
"x86" ["HTTP_ACCEPT_ENCODING"]=> string(13) "gzip, deflate"
["HTTP_USER_AGENT"]=> string(89) "Mozilla/4.0 (compatible; MSIE 7.0;
Windows NT 5.1; .NET CLR 1.1.4322; .NET CLR 2.0.50727)" ["HTTP_HOST"]=>
string(15) "moa.XXX.com" ["HTTP_CONNECTION"]=> string(10) "Keep-Alive"
["HTTP_COOKIE"]=> string(42) "PHPSESSID=45f4ceaef2ff8824143aad70569ba022"
["PATH"]=> string(28) "/usr/local/bin:/usr/bin:/bin"
["SERVER_SIGNATURE"]=> string(0) "" ["SERVER_SOFTWARE"]=> string(102)
"Apache/2.0.54 (Debian GNU/Linux) PHP/5.2.0-0.dotdeb.1 with Suhosin-Patch
mod_ssl/2.0.54 OpenSSL/0.9.7e" ["SERVER_NAME"]=> string(15) "moa.XXX.com"
["SERVER_ADDR"]=> string(12) "1.2.3.4" ["SERVER_PORT"]=> string(2) "80"
["REMOTE_ADDR"]=> string(12) "4.5.6.7" ["DOCUMENT_ROOT"]=> string(22)
"/home/www/moa/XXX/" ["SERVER_ADMIN"]=> string(18) "[no address given]"
["SCRIPT_FILENAME"]=> string(30) "/home/www/moa/XXX/menu.php"
["REMOTE_PORT"]=> string(5) "33073" ["GATEWAY_INTERFACE"]=> string(7)
"CGI/1.1" ["SERVER_PROTOCOL"]=> string(8) "HTTP/1.1" ["REQUEST_METHOD"]=>
string(3) "GET" ["QUERY_STRING"]=> string(11) "module_id=5"
["REQUEST_URI"]=> string(21) "/menu.php?module_id=5" ["SCRIPT_NAME"]=>
string(9) "/menu.php" ["PHP_SELF"]=> string(9) "/menu.php"
["REQUEST_TIME"]=> int(1163034668) ["argv"]=> array(1) { [0]=> string(11)
"module_id=5" } ["argc"]=> int(1) }
*Fatal error*: Call to undefined function conn() in
*/var/www/moa/XXX/security/session.php* on line *109* on line *109*
--
Edit bug report at http://bugs.php.net/?id=39484&edit=1
--
Try a CVS snapshot (PHP 4.4):
http://bugs.php.net/fix.php?id=39484&r=trysnapshot44
Try a CVS snapshot (PHP 5.2):
http://bugs.php.net/fix.php?id=39484&r=trysnapshot52
Try a CVS snapshot (PHP 6.0):
http://bugs.php.net/fix.php?id=39484&r=trysnapshot60
Fixed in CVS: http://bugs.php.net/fix.php?id=39484&r=fixedcvs
Fixed in release:
http://bugs.php.net/fix.php?id=39484&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=39484&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=39484&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=39484&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=39484&r=support
Expected behavior: http://bugs.php.net/fix.php?id=39484&r=notwrong
Not enough info:
http://bugs.php.net/fix.php?id=39484&r=notenoughinfo
Submitted twice:
http://bugs.php.net/fix.php?id=39484&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=39484&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=39484&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=39484&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=39484&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=39484&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=39484&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=39484&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=39484&r=mysqlcfg