-
-
Notifications
You must be signed in to change notification settings - Fork 168
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
route:after
should not be called on $route→next()
#2418
Comments
I agree that this is a bug in the current implementation. The issue is that the I see two solutions to keep this consistent:
|
I like your first suggestion the most. |
I like the first suggestion as well. It also means we can implement it without a breaking change! |
✅ |
I just encountered the problem while debugging Retour (distantnative/retour-for-kirby#138) that the
route:after
hook is a bit problematic in multilang setups.I would argue the most common use case to hook into a successful routing.
However, the hook is actually called on every route lookup - also if the route does
$this→next()
, which seems counter intuitive as the first route explicitly says "not me" by calling$this→next()
https://github.com/getkirby/kirby/blob/master/src/Http/Router.php#L115-L117
My suggestion would be to move the hook call out of the loop and right before the return. To really only call the hook on routes that do not skip to the next route.
What do you think @bastianallgeier and @lukasbestle?
The text was updated successfully, but these errors were encountered: