|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2005-09-06 21:27 UTC] evert at collab dot nl
Description: ------------ I'm getting random errors when I turn apc on. If an error occurs at a certain page, every time I visit the page the error will re-occur. This was one of the errors, I can't recall the other ones: Fatal error: Cannot access parent:: when current class scope has no parent in /home/filemobile/sabretooth/api/modules/project/Bugbase.php on line 36 My class has a parent and doesn't complain when I use it without apc. I don't really see a pattern, because it happens at completely random scripts. I'm actually using PHP 5.0.4, but it wasn't in the dropdown PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Nov 02 05:00:01 2025 UTC |
The previous fix for this has been reverted because it was incomplete. If you are getting hit by this it means that your code is not being consistent about how it includes the script that defines the parent class. You have some requests that include it from the top level unconditionally such that the class can be declared at compile-time, and then you have other requests on the same server that is trying to do a conditional include (perhaps include_once) on the file thus pushing the class definition down into the executor. We will eventually fix this edge-case, but you really would be better off simply fixing your code and always making sure that the file containing the parent class is included unconditionally at the top level in all cases. For optimal performance in an opcode cached environment there are a couple of simple rules to follow: 1. Never use include_once/require_once 2. Never do conditional function or class definitions eg. if(!function_exists('foo')) { function foo() { } } 3. Take advantage of your cache and use apc_store/fetch to get around per-request overhead like a config.inihi, i'm still getting this error. i'm on php 5.1.2 with apc 3.0.8, on linux. after "touching" the file that accesses the parent class, the error is gone. all file inclusion happens with a autoloader, no global requires or includes. the class definition is included inside a class function of the autoloader. it uses include_once($fileName). $fileName is pulled from a cached className -> filename lookup file. would it be better to change the "include_once($fileName)" to if (!class_exists($className)) { include($fileName); } ? thanks, philFixed in CVS HEAD of APC for php 5.1.x . Please turn on apc.report_autofilter if you want to know what all files are not being cached because they use mixed (runtime and compile-time) inheritance. For the record, code with if(class_exists('xyz')){} is slower than include_once and currently APC has issues with such files being included more than once.