Skip to content

[fix] fix ClosureNavigation caching regression in NavigationFactory#6

Merged
wtorsi merged 2 commits intomainfrom
8.0
Mar 2, 2026
Merged

[fix] fix ClosureNavigation caching regression in NavigationFactory#6
wtorsi merged 2 commits intomainfrom
8.0

Conversation

@baldrys-ed
Copy link
Contributor

NavigationFactory was caching all NavigationInterface instances by ::class, causing all ClosureNavigation instances to share the same cached result regardless of their content.

Add isCacheable(): bool to NavigationInterface:

  • AbstractNavigation returns false (no caching by default)
  • AbstractCachedNavigation returns true
  • ClosureNavigation returns true only when explicit cacheKey is provided

NavigationFactory skips the cache entirely for non-cacheable navigations, building the menu tree fresh on every call.

NavigationFactory was caching all NavigationInterface instances by
::class, causing all ClosureNavigation instances to share the same
cached result regardless of their content.

Add isCacheable(): bool to NavigationInterface:
- AbstractNavigation returns false (no caching by default)
- AbstractCachedNavigation returns true
- ClosureNavigation returns true only when explicit cacheKey is provided

NavigationFactory skips the cache entirely for non-cacheable navigations,
building the menu tree fresh on every call.
In FrankenPHP worker mode, services are singletons shared across requests.
Symfony calls services_resetter->reset() (via Kernel::boot) between requests
for services implementing ResetInterface.

Without reset:
- NavigationFactory::$built persists the same Item objects across requests
- Matcher's SplObjectStorage caches Item→active state by object identity
- Result: first request's active menu item is frozen for all subsequent requests

Fix: NavigationFactory::reset() clears $built; Matcher::reset() clears cache.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@wtorsi wtorsi merged commit 2467f24 into main Mar 2, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants