Problem/Motivation
With PHP-FPM or mod_php, the builder exists for one request and builds one route. However, for persistent app servers like FrankenPHP worker mode, the same builder exists serves many requests.
Reusing the same breadcrumb builder can produce breadcrumbs for a previous route. EasyBreadcrumbBuilder::setRouteContextFromRouteMatch() replaces the builder's injected request context with a context derived from the supplied route match. If a later build has no route, or its route path cannot be resolved to a request, that replacement remains in place. The path-based breadcrumb logic then reads the previous route's path instead of the injected request context's path.
Steps to reproduce
The MR's kernel regression test reproduces this with two calls on the same builder:
- Enable invalid paths, the title segment, and page titles when available. Set capitalization mode to
ucwords. - Create a builder with an injected request context whose path is
/other-path. - Build a breadcrumb using the test route
easy_breadcrumb_test.custom_path. Its breadcrumb should containEasy Breadcrumb Custom Path Test. - Call
build()again on the same builder with aNullRouteMatch.
Expected: the second breadcrumb uses the injected context and contains Other Path. Actual: the builder retains the context from the first build and uses the previous route's path.
Proposed resolution
Return the route-derived request context from a helper and keep it local to the current build. Fall back to the injected context when no route-derived context is available.
API changes
The protected method setRouteContextFromRouteMatch() is replaced by the protected method getRequestContextFromRouteMatch(). Subclasses that override or call the old method need updating.
AI disclosure: I used AI to help prepare the IS and MR (Astra and Opus 5.5).
Issue fork easy_breadcrumb-3626366
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #3
ptmkenny commented