diff --git a/app/Exceptions/PluginIdMismatchException.php b/app/Exceptions/PluginIdMismatchException.php new file mode 100644 index 000000000..c5d050d9b --- /dev/null +++ b/app/Exceptions/PluginIdMismatchException.php @@ -0,0 +1,7 @@ + $data['id'] ?? Str::uuid(), - 'name' => $data['name'] ?? $plugin, + 'name' => $data['name'] ?? Str::headline($plugin), 'author' => $data['author'] ?? 'Unknown', - 'version' => '0.0.0', - 'description' => 'Plugin.json is invalid!', + 'version' => $data['version'] ?? '0.0.0', + 'description' => $exception instanceof PluginIdMismatchException ? $exception->getMessage() : 'Plugin.json is invalid!', 'category' => PluginCategory::Plugin->value, - 'url' => null, + 'url' => $data['url'] ?? null, 'update_url' => null, 'namespace' => 'Error', 'class' => 'Error', @@ -197,7 +201,7 @@ class Plugin extends Model implements HasPluginSettings public function shouldLoad(?string $panelId = null): bool { - return ($this->status === PluginStatus::Enabled || $this->status === PluginStatus::Errored) && (is_null($panelId) || !$this->panels || in_array($panelId, explode(',', $this->panels))); + return $this->fullClass() !== '\\Error\\Error' && ($this->status === PluginStatus::Enabled || $this->status === PluginStatus::Errored) && (is_null($panelId) || !$this->panels || in_array($panelId, explode(',', $this->panels))); } public function canEnable(): bool diff --git a/app/Services/Helpers/PluginService.php b/app/Services/Helpers/PluginService.php index c94a89ecb..de364e49d 100644 --- a/app/Services/Helpers/PluginService.php +++ b/app/Services/Helpers/PluginService.php @@ -54,6 +54,10 @@ class PluginService } } + if ($plugin->namespace === 'Error') { + continue; + } + // Always autoload src directory to make sure all class names can be resolved (e.g. in migrations) $namespace = $plugin->namespace . '\\'; if (!array_key_exists($namespace, $classLoader->getPrefixesPsr4())) {