Skip to content

route:after should not be called on $route→next() #2418

@distantnative

Description

@distantnative

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?

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions