php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #61854 APC breaks relative includes with stat=0 since PHP 5.4
Submitted: 2012-04-25 21:29 UTC Modified: 2012-07-19 19:00 UTC
From: nick at ihighteam dot com Assigned: rasmus (profile)
Status: Closed Package: APC (PECL)
PHP Version: 5.4.3 OS: FreeBSD
Private report: No CVE-ID: None
 [2012-04-25 21:29 UTC] nick at ihighteam dot com
Description:
------------
I am using PHP 5.4.1 and APC 3.1.10.

This bug is probably related to https://bugs.php.net/bug.php?id=59493

Starting with PHP 5.4 using apc.stat=0 with relative includes does no longer work at all. It now produces a warning followed by fatal error.

PHP Warning:  require_once(/srv/http/vhosts/.../htdocs): failed to open stream: Success in /srv/http/vhosts/.../htdocs/index.php on line xx
PHP Fatal error:  require_once(): Failed opening required '' (include_path='.:/usr/share/pear') in /srv/http/vhosts/.../htdocs/index.php on line xx

The same code worked fine with PHP 5.3.

I am not sure if it is meant to break as we already discussed that apc.stat=0 + relative paths is "difficult". But at least the error message could be improved.


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2012-04-26 05:35 UTC] pajoye@php.net
-Status: Open +Status: Duplicate
 [2012-04-26 05:35 UTC] pajoye@php.net
duplicate of #59493
 [2012-05-03 20:47 UTC] micxer at micxer dot de
This is not a duplicate of #59493 since the suggested solution using 
apc.canonicalize=1 doesn't work.
 [2012-05-07 12:59 UTC] lstrojny@php.net
@Pierre: see Michaels comment above, care to reopen?
 [2012-05-20 01:32 UTC] nick at ihighteam dot com
Please re-open.  I'm having the same issue with PHP 5.4.3 and APC 3.1.10 on FreeBSD 8.  Any code referencing a file in a parent directory causes a meltdown:

Ex:  require('../file.php')

I haven't found a fix, other converting everything to absolute paths, which isn't practical at the moment.
 [2012-05-20 09:31 UTC] pajoye@php.net
@nick at ihighteam dot com

If you use relative includes, then disable stat=0.

@micxer at micxer dot de

It sadly is the same issue. The work around presented may not work but the cause 
of the problem is exactly the same.
 [2012-05-20 10:41 UTC] pierre at archlinux dot de
I am fine with APC not caching relative includes. But while such code still worked fine with 5.3 it wont with 5.4. Again: 5.3 would still include that file in question and 5.4 wont. Also see: http://de3.php.net/manual/en/apc.configuration.php#ini.apc.stat

There are projects which mostly use absolute includes but include third party libs which do not. Setting stat=0 still helps here.

From a user's perspective it is hard to define this as intended behavior rather than a regression.
 [2012-05-20 10:46 UTC] pajoye@php.net
5.3 had the same issues, only under less circumstances.
 [2012-05-20 15:18 UTC] nick at ihighteam dot com
@pajoye: you are right.  That does at least make the code run.

@pierre:  Like you said, 5.3 would at least work with stat=0 and relative includes.  This bug was a complete surprise since I had hoped to upgrade to PHP 5.4 and APC seamlessly without any code modifications.  Of course, I can always do stat=0, but then I lose some performance that I had before.  I will keep checking on this issue, but in the meanwhile, I'll probably begin the process of removing all relative requires and includes.
 [2012-05-20 15:18 UTC] nick at ihighteam dot com
-: pierre@archlinux.de +: nick at ihighteam dot com -Operating System: Arch Linux +Operating System: FreeBSD -PHP Version: 5.4.1RC2 +PHP Version: 5.4.3
 [2012-05-20 15:26 UTC] pajoye@php.net
Again, it was happening with 5.3 too.

Simply do not use stats=0 with relative paths or with uncontrolled environments, 
like you seem to have.

I am sorry that you have not met that but there is nothing we can do yet against 
that.
 [2012-05-20 15:51 UTC] nick at ihighteam dot com
@pajoye:  In the long run, absolute paths are better so that stat() is never called, anyway.  I think we can change our code within a week to work with stat=0.  The newer magic constants, such as __DIR___ and the like, make it much easier to do this.
 [2012-05-20 18:28 UTC] pierre at archlinux dot de
I get it, you don't want to solve this issue. But please don't pretend we make things up here. Different people already confirmed that there was a change in behavior when switching from PHP 5.3 to 5.4. This is an easily reproducible fact.

Anyway, if the current behavior is the intended one, please consider the following:
* Replace the last paragraph of http://de3.php.net/manual/en/apc.configuration.php#ini.apc.stat with a note that relative includes are not supported at all.
* Remove the apc.canonicalize option as it is now obsolete and cannot work as documented.

I am not sarcastic here btw.. Either the current behavior with PHP 5.4 needs to be fixed or 5.3 and the documentation needs to be clarified. Either way something should be done about this; they cannot all be right.
 [2012-05-20 22:53 UTC] pajoye@php.net
@pierre

it is not that I do not want. It is a matter of how it works. Yes it could be 
possible to do it but I don't think the price is worth it.

If you feel like you could do it without breaking BC or impacting the stat=0 
performance, then please go ahead.

As of the doc, yes, it is long due, at least a note to warn users about this 
effect. Patch welcome here too :)
 [2012-07-19 19:00 UTC] rasmus@php.net
This is fixed in svn now. Grab trunk and give it a try.
 [2012-07-19 19:00 UTC] rasmus@php.net
-Status: Duplicate +Status: Closed -Assigned To: +Assigned To: rasmus
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Apr 24 08:01:29 2024 UTC