F
Filament2mo ago
Hessam

Issue with registerNavigationItems in Octane and RoadRunner

Hi everyone, I’m encountering an issue when trying to display menu items based on user access in an Octane environment with RoadRunner. The problem arises only when using Octane, as everything works fine with a simple web server. The core issue is that Octane boots once and does not clear variables between requests until the worker is reset. This behavior causes old navigation items to persist across requests, leading users to see unrelated menus from previous routes. Here’s the relevant code from my provider: Filament::serving(function (): void { Filament::registerPanel(Filament::getCurrentPanel()); $menuItems = [......] foreach ($menuItems as $menuItem) { if ($menuItem->menu['showable']) { Filament::registerNavigationItems([ NavigationItem::make($menuItem->menu['title'] ?? 'Default title') ->url(route('filament.manager.resources.contents.report', ['record' => $menuItem->slug])) ->group($menuItem->menu['navigation_group'] ?? 'Default group') ->sort(3), ]); } } }); As you can see, on each request, I register navigation items based on the current user's access. However, when the page is refreshed, the user can see unrelated menus from previous routes because registerNavigationItems is not being cleared between requests. I believe the issue lies in the navigationItems method in the NavigationManager class, where the items are just appended: public function navigationItems(array $items): static { $this->navigationItems = [ ...$this->navigationItems, ...$items, ]; return $this; } Would it be possible to clear the items and then fill them again on each request? Or do you have any ideas on how I can resolve or improve this approach to avoid displaying outdated navigation items? Any advice would be greatly appreciated!
0 Replies
No replies yetBe the first to reply to this messageJoin
Want results from more Discord servers?
Add your server