Make plugin id in artisan commands also case insensitive (#2252)

This commit is contained in:
Boy132
2026-02-19 14:57:19 +01:00
committed by GitHub
parent 1bbbcd0e25
commit dead664e4d
5 changed files with 13 additions and 12 deletions

View File

@@ -16,7 +16,7 @@ class DisablePluginCommand extends Command
{ {
$id = $this->argument('id') ?? $this->choice('Plugin', Plugin::pluck('name', 'id')->toArray()); $id = $this->argument('id') ?? $this->choice('Plugin', Plugin::pluck('name', 'id')->toArray());
$plugin = Plugin::find($id); $plugin = Plugin::find(str($id)->lower()->toString());
if (!$plugin) { if (!$plugin) {
$this->error('Plugin does not exist!'); $this->error('Plugin does not exist!');

View File

@@ -18,7 +18,7 @@ class InstallPluginCommand extends Command
{ {
$id = $this->argument('id') ?? $this->choice('Plugin', Plugin::pluck('name', 'id')->toArray()); $id = $this->argument('id') ?? $this->choice('Plugin', Plugin::pluck('name', 'id')->toArray());
$plugin = Plugin::find($id); $plugin = Plugin::find(str($id)->lower()->toString());
if (!$plugin) { if (!$plugin) {
$this->error('Plugin does not exist!'); $this->error('Plugin does not exist!');

View File

@@ -18,7 +18,7 @@ class UninstallPluginCommand extends Command
{ {
$id = $this->argument('id') ?? $this->choice('Plugin', Plugin::pluck('name', 'id')->toArray()); $id = $this->argument('id') ?? $this->choice('Plugin', Plugin::pluck('name', 'id')->toArray());
$plugin = Plugin::find($id); $plugin = Plugin::find(str($id)->lower()->toString());
if (!$plugin) { if (!$plugin) {
$this->error('Plugin does not exist!'); $this->error('Plugin does not exist!');

View File

@@ -17,7 +17,7 @@ class UpdatePluginCommand extends Command
{ {
$id = $this->argument('id') ?? $this->choice('Plugin', Plugin::pluck('name', 'id')->toArray()); $id = $this->argument('id') ?? $this->choice('Plugin', Plugin::pluck('name', 'id')->toArray());
$plugin = Plugin::find($id); $plugin = Plugin::find(str($id)->lower()->toString());
if (!$plugin) { if (!$plugin) {
$this->error('Plugin does not exist!'); $this->error('Plugin does not exist!');

View File

@@ -39,7 +39,7 @@ class PluginService
/** @var ClassLoader $classLoader */ /** @var ClassLoader $classLoader */
$classLoader = File::getRequire(base_path('vendor/autoload.php')); $classLoader = File::getRequire(base_path('vendor/autoload.php'));
$plugins = Plugin::query()->orderBy('load_order')->get(); $plugins = Plugin::orderBy('load_order')->get();
foreach ($plugins as $plugin) { foreach ($plugins as $plugin) {
try { try {
// Filter out plugins that are not compatible with the current panel version // Filter out plugins that are not compatible with the current panel version
@@ -138,7 +138,7 @@ class PluginService
return; return;
} }
$plugins = Plugin::query()->orderBy('load_order')->get(); $plugins = Plugin::orderBy('load_order')->get();
foreach ($plugins as $plugin) { foreach ($plugins as $plugin) {
try { try {
if (!$plugin->shouldLoad($panel->getId())) { if (!$plugin->shouldLoad($panel->getId())) {
@@ -172,7 +172,7 @@ class PluginService
{ {
$newPackages ??= []; $newPackages ??= [];
$plugins = Plugin::query()->orderBy('load_order')->get(); $plugins = Plugin::orderBy('load_order')->get();
foreach ($plugins as $plugin) { foreach ($plugins as $plugin) {
if (!$plugin->composer_packages) { if (!$plugin->composer_packages) {
continue; continue;
@@ -434,7 +434,7 @@ class PluginService
/** @param array<string, mixed> $data */ /** @param array<string, mixed> $data */
private function setMetaData(string|Plugin $plugin, array $data): void private function setMetaData(string|Plugin $plugin, array $data): void
{ {
$path = plugin_path($plugin instanceof Plugin ? $plugin->id : $plugin, 'plugin.json'); $path = plugin_path($plugin->id, 'plugin.json');
if (File::exists($path)) { if (File::exists($path)) {
$pluginData = File::json($path, JSON_THROW_ON_ERROR); $pluginData = File::json($path, JSON_THROW_ON_ERROR);
@@ -443,7 +443,6 @@ class PluginService
File::put($path, json_encode($pluginData, JSON_THROW_ON_ERROR | JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES)); File::put($path, json_encode($pluginData, JSON_THROW_ON_ERROR | JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES));
$plugin = $plugin instanceof Plugin ? $plugin : Plugin::findOrFail($plugin);
$plugin->update($metaData); $plugin->update($metaData);
} }
} }
@@ -464,6 +463,8 @@ class PluginService
public function updateLoadOrder(array $order): void public function updateLoadOrder(array $order): void
{ {
foreach ($order as $i => $plugin) { foreach ($order as $i => $plugin) {
$plugin = Plugin::firstOrFail(str($plugin)->lower()->toString());
$this->setMetaData($plugin, [ $this->setMetaData($plugin, [
'load_order' => $i, 'load_order' => $i,
]); ]);
@@ -472,7 +473,7 @@ class PluginService
public function hasThemePluginEnabled(): bool public function hasThemePluginEnabled(): bool
{ {
$plugins = Plugin::query()->orderBy('load_order')->get(); $plugins = Plugin::orderBy('load_order')->get();
foreach ($plugins as $plugin) { foreach ($plugins as $plugin) {
if ($plugin->isTheme() && $plugin->status === PluginStatus::Enabled) { if ($plugin->isTheme() && $plugin->status === PluginStatus::Enabled) {
return true; return true;
@@ -487,7 +488,7 @@ class PluginService
{ {
$languages = []; $languages = [];
$plugins = Plugin::query()->orderBy('load_order')->get(); $plugins = Plugin::orderBy('load_order')->get();
foreach ($plugins as $plugin) { foreach ($plugins as $plugin) {
if ($plugin->status !== PluginStatus::Enabled || !$plugin->isLanguage()) { if ($plugin->status !== PluginStatus::Enabled || !$plugin->isLanguage()) {
continue; continue;
@@ -504,7 +505,7 @@ class PluginService
return config('panel.plugin.dev_mode', false); return config('panel.plugin.dev_mode', false);
} }
private function handlePluginException(string|Plugin $plugin, Exception $exception): void private function handlePluginException(Plugin $plugin, Exception $exception): void
{ {
if ($this->isDevModeActive()) { if ($this->isDevModeActive()) {
throw ($exception); throw ($exception);