ZF-8984: Fatal error: Cannot redeclare class Zend_Exception in [...]/Exception.php on line 28 (xcache enabled)


With php < 5.3 and xcache enabled the Zend_Exception throws a Fatal Error as described on Nabble.

Disabling xcache or removing the else section solves the problem but thats not an acceptable resolution.


We are no able to update due this error!

This is, quite simply, bad behavior on the part of xcache; other opcode caches, such as APC and Zend Optimizer, behave correctly with the conditional class definition.

I will attempt to resolve the issue, but you should also report it upstream to the xcache developers.

Thanks. I opened a ticket in the xcache trac. Ticket #234

It appears to be resolved in XCache 1.3.0.

Since the issue was upstream, and the upstream provider has a release that corrects the issue, no further work needs to be done on the ZF side.

If you are using XCache and have the issue as reported, upgrade to XCache 1.3.0.

We use Ubuntu 9.10 from an automated installation with stable packages and security updates. We have a policy to only use supported stable packages so I'm not able/allowed to use XCache > 1.2.2 for now. Thank you for your efforts.

We have the same problem. We removed not needed Zend_Exception class declaration from Zend/Exception.php to use ZF 1.10. Seems to be the only way at the moment.

Another policy is: Do not to change the library to stay upgradable. ;-) So we are really not able to use it at all.

@Andre: This change works under normal installs of PHP; the problem here is entirely in a 3rd party, unofficial extension to PHP -- and, as noted, newer releases to that extension correct the issue. We simply cannot target every possible extension combination possible to PHP.

If you are not using svn:externals, you can simply modify the library/Zend/Exception.php file to remove the condition.

Thanks Matthew, but thats exactly how its implemented in your application - as an svn:externals property in your library and it will be updated/exported in the build process. In development it's ok to remove the condition...

ups: ... how its implemented in 'our' application.

Could this (see attached file) be a solution? (untested)

Thanks for the path. I'll try it next week. End of this week we have a release and I don't think that it would make all happy to change the library shortly before that. ;-)

That patch would definitely solve the issue; I'll apply it today for the 1.10.1 release.


Patch applied, with modifications, to trunk and 1.10 release branch.

Thanks a lot, works fine!