pimcore icon indicating copy to clipboard operation
pimcore copied to clipboard

[Bugfix]: disallow matching pimcore context via route name

Open jdreesen opened this issue 3 months ago • 2 comments

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.

jdreesen avatar Sep 22 '25 14:09 jdreesen

Review Checklist

  • [ ] Target branch (11.5 for bug fixes, others 11.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

github-actions[bot] avatar Sep 22 '25 14:09 github-actions[bot]