2009年12月16日星期三

[fw-mvc] Zend_Exception breaking changes since 19661

Problem:
In 19661 (trunk) Mathew has committed a workaround for php's odd
behavior of swallowing stack traces when re-throwing an exception. But
the fix is by throwing the special Zend_Exception - effectively
swallowing the old exception for consumption.

Use case:
I implemented a custom redirecting machinery that relies on exceptions
to work - the reason is that when a redirect happens in stock ZF the
execution is not terminated (I should call return in the action - but
what about redirects not in the action method, but some other helper
function?).
What I did is throw a special exception, then wrap the call to
Zend_Controller_Front::dispatch() in try/catch and wait for this
exception. If caught - redirect and terminate. (Yes, I had to
monkey-patch Zend_Test_PHPUnit_ControllerTestCase::dispatch() so set
the FC::throwExceptions(true)).

With the new change this is no longer possible.


--
My place to share my ideas:
http://bolddream.com (now live :)

没有评论: