Issue Type: Bug Created: 2009-10-27T05:14:54.000+0000 Last Updated: 2011-05-03T11:08:48.000+0000 Status: Resolved Fix version(s): - 1.10.7 (28/Jul/10)
Reporter: Marcus Bointon (synchro) Assignee: Shahar Evron (shahar) Tags: - Zend_Http_Cookie
Related issues: Attachments: - ZF-8158.diff
In several places (I've only inidicated ones I've run into), class_exists() is called prior to calling Zend_Loader, however, it's called without overriding the default autoload behaviour, and is thus likely to interfere with autoload behaviour happening outside the framework and disable the internal use of Zend_Loader for Zend components. This was introduced in Zend framework 1.8.2. Various instances of this approach have since been fixed as bugs, such as http://framework.zend.com/issues/browse/ZF-6660 and http://zendframework.com/issues/browse/ZF-6591 so I think these should be fixed too.
I suspect that all uses of class_exists should be checked.
Posted by Marcus Bointon (synchro) on 2010-06-30T09:29:47.000+0000
Yes, this is still present in 1.10.6 and it means I can't use ZF at all!
Posted by Marcus Bointon (synchro) on 2010-06-30T10:10:29.000+0000
A quick grep finds me 97 instances of class_exists without a 'false' second parameter (though I'm not trying to resurrect #10053 here). I don't know if it's worth me generating what would be a pretty huge patch for all of them, plus I don't know ZF well enough to be able to fix all of them sensibly - are partial patches welcome?
Posted by Anthon Pang, VIP Software Technologies Inc. (vipsoft) on 2010-07-06T22:50:48.000+0000
(I've deleted my earlier comment as it was off-topic.)
ZF-6660 and ZF-6591 were special cases. In general, we want class_exists() without the second parameter (false) whenever it precedes a loadClass(), because it allows other autoloaders to execute.
If you've implemented your own autoloader, just make sure it doesn't throw an exception when the file/class is not found.
Posted by Marcus Bointon (synchro) on 2010-07-07T00:20:59.000+0000
It's a shame you deleted your comment as it contained two of the instances that I'd run into! I'm calling Zend_Feed:import, which correctly uses Zend_Loader to load Zend_Http_Client, which correctly uses Zend_Loader to load Zend_Uri, but unfortunately that doesn't use Zend_Loader and calls class_exists before trying to load Zend_Uri_Http and thus breaks. Consistency is the key here, and your previously posted fix works perfectly in this case. "allowing other autoloaders to execute" is precisely what's breaking ZF; my autoloader is not compatible with ZF, nor should it need to be, and it's why Zend_Loader exists. Zend_Loader DOES call class_exists without the second param, so we should be using it everywhere, and not clumsily circumventing it randomly. As it stands it renders ZF unusable as a component library; if I can't load a component and call a function in it without breaking my app, it's broken. I'll post a patch for just this specific case rather than trying to fix anything bigger. Given that ZF2 has a very clear aim of doing everything with Zend_Loader via autoload, it seems silly not to head in vaguely the same direction in 1.x.
Posted by Marcus Bointon (synchro) on 2010-07-07T13:57:00.000+0000
Diff against 1.10.6 to fix a couple of the mentioned instances of this problem.
Posted by Shahar Evron (shahar) on 2010-07-08T04:54:49.000+0000
Fixed for Zend_Http_Client in trunk rev.22537 (also noticed one more place where class_exists was used)
Posted by Shahar Evron (shahar) on 2010-07-08T05:01:32.000+0000
Fixed for Zend_Uri in trunk rev.22538
Posted by Shahar Evron (shahar) on 2010-07-08T05:48:54.000+0000
Fixes for Zend_Uri and Zend_Http_Client merged to release branch in 22539. Thanks for the patch!
Posted by Satoru Yoshida (satoruyoshida) on 2011-05-03T11:08:47.000+0000
marking this issue as resolved in 1.10.7
Have you found an issue?
See the Overview section for more details.