ZF-8525: Zend_Filter::filterStatic() fails with non-Zend namespaces.
Description
For example, we have some of our own filters in a "Webready" class structure so we have:
Zend_Filter::addDefaultNamespaces( array('Webready_Filter', 'Zend_Filter') );
but this causes an error if the filter only exists in the zend library:
$filtered = Zend_Filter::filterStatic( 'testTest', 'Word_CamelCaseToUnderscore' ) );
ERROR: include(Webready/Filter/Word/CamelCaseToUnderscore.php): failed to open stream: No such file or directory Zend/Loader.php:83 Zend/Loader.php:83 Zend/Loader/Autoloader.php:474 Zend/Loader/Autoloader.php:130 Zend/Filter.php:172
The above error is "valid" since it's true that the file doesn't exist in our library but it does in Zend.
The problem is two fold. First Zend_Filter::filterStatic has:
if (!class_exists($className)) { try { Zend_Loader::loadClass($className); } catch (Zend_Exception $ze) { continue; } }
The class_exists needs a false as the second argument otherwise class exists invokes the autoloader.
Second, if you add false, the loadClass still attempts to load the file without checking if it exists first:
Error: include(Webready/Filter/Word/CamelCaseToUnderscore.php): failed to open stream: No such file or directory Zend/Loader.php:83 Zend/Loader.php:83 Zend/Filter.php:174
Comments
Posted by Thomas Weidner (thomas) on 2009-12-11T13:33:29.000+0000
Duplication of ZF-7918