chore: Prevent users from caching Config (#2048)

This commit is contained in:
MartinOscar
2025-12-28 00:50:36 +00:00
committed by GitHub
parent 9af608f808
commit d72e075977
5 changed files with 39 additions and 3 deletions

View File

@@ -0,0 +1,19 @@
<?php
namespace App\Console\Commands\Overrides;
use Illuminate\Foundation\Console\ConfigCacheCommand as BaseConfigCacheCommand;
class ConfigCacheCommand extends BaseConfigCacheCommand
{
/**
* Prevent config from being cached
*/
public function handle()
{
$this->components->warn('Configuration caching has been disabled.');
$this->line(' Reason: This application uses dynamic plugins. Caching config');
$this->line(' prevents /plugins/config/*.php files from being loaded correctly.');
}
}

View File

@@ -0,0 +1,18 @@
<?php
namespace App\Console\Commands\Overrides;
use Illuminate\Foundation\Console\OptimizeCommand as BaseOptimizeCommand;
class OptimizeCommand extends BaseOptimizeCommand
{
/**
* Prevent config from being cached
*
* @return array<string, string>
*/
protected function getOptimizeTasks()
{
return array_except(parent::getOptimizeTasks(), 'config');
}
}

View File

@@ -823,7 +823,6 @@ class Settings extends Page implements HasSchemas
$this->writeToEnvironment($data);
Artisan::call('config:clear');
Artisan::call('queue:restart');
$this->redirect($this->getUrl());

View File

@@ -165,8 +165,6 @@ class PanelInstaller extends SimplePage implements HasForms
throw new Halt(trans('installer.exceptions.write_env'));
}
Artisan::call('config:clear');
}
public function runMigrations(): void

View File

@@ -3,6 +3,7 @@
namespace App\Traits;
use Illuminate\Support\Env;
use Illuminate\Support\Facades\Artisan;
use RuntimeException;
trait EnvironmentWriterTrait
@@ -17,5 +18,6 @@ trait EnvironmentWriterTrait
public function writeToEnvironment(array $values = []): void
{
Env::writeVariables($values, base_path('.env'), true);
Artisan::call('config:clear');
}
}