[Bugfix]: disallow matching pimcore context via route name
Pimcore context can be configured via request matchers, e.g. (which is the only way it is used by Pimcore itself)
pimcore:
context:
api:
routes:
- { path: ^/my/api/$ }
It also allows matching via route name, like:
pimcore:
context:
api:
routes:
- { route: my_api }
But the latter does not actually work!
When the route with name my_api the context is resolved as default instead of api.
The reason is, that it is only resolved the first time it gets checked (which is good). But this first check happens way before the route is matched by Symfony, which listens on kernel.request with priority 32, and populates the necessary _route attribute in the request. In fact, Pimcore has listeners on this event with priority 560 (CustomAdminEntryPointCheckListener), 512 (RoutingListener) or 120 (FullPageCacheListener) which all check the context (and thus initialize it, which is bad).
This means those routes never match and will always be default.
Thus, I propose to disallow using the route matcher for the context.
Review Checklist
- [ ] Target branch (
11.5for bug fixes, others11.x) - [ ] Tests (if it's testable code, there should be a test for it - get help)
- [ ] Docs (every functionality needs to be documented, see here)
- [ ] Migration incl.
install.sql(e.g. if the database schema changes, ...) - [ ] Upgrade notes (deprecations, important information, migration hints, ...)
- [ ] Label
- [ ] Milestone
Quality Gate passed
Issues
0 New issues
0 Accepted issues
Measures
0 Security Hotspots
0.0% Coverage on New Code
0.0% Duplication on New Code