Clear filament cache when installing a plugin#2017
Conversation
📝 WalkthroughWalkthroughModified the plugin installation process to refresh cached Filament components. Added an explicit import for the Filament facade and introduced logic to iterate through all registered Filament panels, clearing cached components after migrations and seeders execute. Changes
Pre-merge checks❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (1)
app/Services/Helpers/PluginService.php (1)
316-335: Consider adding cache clearing touninstallPlugin.The
installPluginmethod now clears cached Filament components, butuninstallPlugindoes not. When a plugin is uninstalled, its components should also be cleared from the cache to prevent stale references.🔎 Suggested fix to add cache clearing in uninstallPlugin
public function uninstallPlugin(Plugin $plugin, bool $deleteFiles = false): void { try { $pluginPackages = json_decode($plugin->composer_packages, true, 512); $this->rollbackPluginMigrations($plugin); if ($deleteFiles) { $this->deletePlugin($plugin); } else { $this->setStatus($plugin, PluginStatus::NotInstalled); } $this->buildAssets(); $this->manageComposerPackages(oldPackages: $pluginPackages); + + foreach (Filament::getPanels() as $panel) { + $panel->clearCachedComponents(); + } } catch (Exception $exception) { $this->handlePluginException($plugin, $exception); } }
📜 Review details
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
app/Services/Helpers/PluginService.php(2 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
app/Services/Helpers/PluginService.php (3)
app/Providers/Filament/AdminPanelProvider.php (1)
panel(16-56)app/Providers/Filament/AppPanelProvider.php (1)
panel(13-40)app/Providers/Filament/ServerPanelProvider.php (1)
panel(17-55)
🔇 Additional comments (2)
app/Services/Helpers/PluginService.php (2)
10-10: LGTM!The Filament facade import is correctly added and necessary for the cache clearing functionality introduced below.
292-294: Cache clearing after plugin installation is appropriate.The placement of
clearCachedComponents()after migrations and seeders ensures newly registered plugin components are discovered on the next request. This approach is sound for plugin installations.
No description provided.