ZF-11337: Zend_Cache_Frontend_Class::__call shoud throw an Exception on invalid method
Description
When the __call function is called, a call_user_func_array function is invoked, wrapped in a try/catch. But the call_user_func_array function returns a warning (not an exception) with an non-existent method name, blocking a good tracing.
I think that the line 223 (1.11.5) should be out of the try/catch and provide an exception itself in case of errors.
if (!$return = call_user_func_array(array($this->_cachedEntity, $name), $parameters))
throw new Exception ('Unable to call ' . $name . ' bla bla bla');
Regards, Sergio
Comments
Posted by Marc Bennewitz (private) (mabe) on 2011-05-03T21:26:52.000+0000
We don't know what the return value of the called function/method should be. A value of FALSE can be valid, too! If you call the method without the class cache you are going in the same error. -> The class cache is only for caching method results and not for adding features or changing functionalities.
Posted by Sergio Vaccaro (hujuice) on 2011-05-08T09:11:12.000+0000
What I meant is a bit different. The problem is to find a wrong call. An example could be the clearest explanation.
I have a class, successfully cached. After a while, I delete a method or change its name. Or maybe some coder mistyped the method name. How to find that wrong call? (Ok, there are many solutions).
When a wrong chunk of code calls the cached class, I have an error message generated by 'call_user_function' in Zend_Cache_Frontend_Class, but this way I'm not able to find where the wrong calling code is.
This is not so helpful.
If I skip caching, this kind of error is a fatal error with a file/number reference:
This is why I thought to an exception.
Best regards, Sergio
Posted by Marc Bennewitz (private) (mabe) on 2011-05-09T21:53:52.000+0000
I'll add an is_callable check and throw an exception like Zend_Cache_Frontend_Function
Posted by Sergio Vaccaro (hujuice) on 2011-05-10T14:12:28.000+0000
IMO, it would be an improvement. Sergio
Posted by Marc Bennewitz (private) (mabe) on 2011-05-10T21:09:39.000+0000
implemented in r24031 (trunk) & r24032 (1.11 branch)