Existing Class not found using XCache and PHP 5.3.2

748 views Asked by At

I'm getting the weirdest problem using XCache and PHP 5.3.2 there is a class 'Vb_Post' that won't be loaded by PHP and throws a Fatal Error: Fatal error: Class 'Vb_Post' not found in /Users/mario/Sites/m.techspot/app/models/Vb/Comments.php on line 5

If I run the same code with PHP 5.2 and XCache 1.2.2 or PHP 5.3.2 and APC everything runs fine. Is there a workaround/fix to this and does anyone know if this is a known issue, I've googled like crazy and haven't been able to come up with any solutions, I've read some people having similar issues using php 5.3.2 and APC but it looks like I'm suffering from the opposite.

I don't know exactly when this issue appeared but it worked fine until a week ago, and there were no major code change. The same problem happens in my development computer and on the server, both running the same mentioned software.

I'm pretty sure it has something to do with XCache since the first time it runs everything is OK, the error appears on subsequent requests.

Could it be that there's some hidden character that's causing this issue?

1

There are 1 answers

0
Mario Estrada On BEST ANSWER

OK I found a work around for this problem. At the top of the Vb_Post class I was loading some classes that also referenced the Vb_Post class, apparently it was causing some kind of conflict that prevented the class from being loaded when cached.

The fix: Moving the require_once('SomeClass.php') inside the class just before actually using it.

...
public function someAction()
{
    require_once('SomeClass.php');
    var $sc = new SomeClass();
    ...
}
...

So, after battling with these for about a week, this is the best solution I've come up with, hope this helps someone else.