From 328461b0938ea74131a8cee693944886bbfcd202 Mon Sep 17 00:00:00 2001 From: xboard Date: Sat, 12 Jul 2025 21:54:12 +0800 Subject: [PATCH] fix(plugin): auto-remove plugin record if class file is missing --- app/Services/Plugin/PluginManager.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/app/Services/Plugin/PluginManager.php b/app/Services/Plugin/PluginManager.php index f6b4f3a..4edd1ff 100644 --- a/app/Services/Plugin/PluginManager.php +++ b/app/Services/Plugin/PluginManager.php @@ -8,6 +8,7 @@ use Illuminate\Support\Facades\File; use Illuminate\Support\Facades\View; use Illuminate\Support\Facades\Route; use Illuminate\Support\Facades\Artisan; +use Illuminate\Support\Facades\Log; use Illuminate\Support\Str; use Symfony\Component\Finder\Finder; @@ -51,13 +52,15 @@ class PluginManager if (!class_exists($pluginClass)) { $pluginFile = $this->getPluginPath($pluginCode) . '/Plugin.php'; if (!File::exists($pluginFile)) { - throw new \Exception("Plugin class file not found: {$pluginFile}"); + Log::error("Plugin class file not found: {$pluginFile}"); + return null; } require_once $pluginFile; } if (!class_exists($pluginClass)) { - throw new \Exception("Plugin class not found: {$pluginClass}"); + Log::error("Plugin class not found: {$pluginClass}"); + return null; } $plugin = new $pluginClass($pluginCode); @@ -265,6 +268,7 @@ class PluginManager $plugin = $this->loadPlugin($pluginCode); if (!$plugin) { + Plugin::where('code', $pluginCode)->delete(); throw new \Exception('Plugin not found: ' . $pluginCode); }