-
-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[NFR] Allow action forwarding anywhere inside dispatch loop following Exception handling in "dispatch:beforeException" #12336
Comments
I agree for dispatch loop, but in before dispatch loop and after forward should not be possible. |
@Jurigag Absolutely. Only between https://github.com/phalcon/cphalcon/blob/master/phalcon/dispatcher.zep#L390 and https://github.com/phalcon/cphalcon/blob/master/phalcon/dispatcher.zep#L625. I expect the following hooks to work:
Is there a reason why this couldn't be achieved by wrapping in try {
if eventsManager->fire("dispatch:beforeExecuteRoute", this) === false {
continue;
}
} catch \Exception, e {
if this->{"_handleException"}(e) === false {
if this->_finished === false {
continue;
}
} else {
throw e;
}
} It looks like a straightforward fix to me, unless I'm missing something. Thanks! |
@temuri416 THis is already implemented in upcoming bugfix for dispatcher the provides proper event throwing anywhere inside the dispatch sequence. Forthcoming documentation will update the current dispatcher.rst page with improved clarification. mark as closed . Reference #11819 and Pull request - 12209 |
Duplicate of #11819. |
@temuri416 You can see the screenshot here of all the tests covered in the PR which include exceptions and events in the beforeDispatchLoop (and afterDispatchLoop). Your case above is covered as well as a huge amount of cases that may or may not have worked at one point but got mangled overtime due to refactoring. If there any any missing please let me know. |
Thanks a lot. IMO this is a fix of the huge importance. Looking forward to resolution. Gonna take a look at the PR for details... Cheers. |
Fixing core things like this has exposed some flaws in Zephir ... specifically double exceptions and memory mapping of variables that is causing a segfault. So as soon as we can get this fixed upstream, we can get tests to pass, update docs, and this will be one of last things in 3.0.2 |
@virgofx still keep in mind, that from logic point of view forwarding from beforeDispatchLoop or afterDispatchLoop should not be possible. I hope it's not in your PR. |
It is, and it does make sense. |
How it make sense ? Why we can forward action if we not in dispatch loop ? |
See #2851 for more info.
From the official documentation at https://docs.phalconphp.com/en/latest/reference/dispatching.html#handling-not-found-exceptions:
The above code does not work as it is only called from outside the dispatch loop.
It would be very valuable to be able to forward controller actions from inside
dispatch:beforeException
event handlers.At the moment the only case when the forwarding works is if Exception was thrown inside controllers.
Thanks.
The text was updated successfully, but these errors were encountered: