mirror of
https://github.com/InvoiceShelf/InvoiceShelf.git
synced 2026-04-19 03:04:05 +00:00
Fix infinite request loop on File Disk admin page
configureMediaDisk() was calling FileDisk::setConfig() which mutates the global filesystems.default config on every request. This caused cascading requests on the File Disk admin page. Now registers the media disk config directly without changing the global default filesystem.
This commit is contained in:
@@ -186,9 +186,21 @@ class AppServiceProvider extends ServiceProvider
|
||||
: FileDisk::where('set_as_default', true)->first();
|
||||
|
||||
if ($disk) {
|
||||
$disk->setConfig();
|
||||
// Register the disk config without changing the global default.
|
||||
// setConfig() mutates filesystems.default which causes side effects.
|
||||
$prefix = env('DYNAMIC_DISK_PREFIX', 'temp_');
|
||||
config(['media-library.disk_name' => $prefix.$disk->driver]);
|
||||
$diskName = $prefix.$disk->driver;
|
||||
$credentials = collect(json_decode($disk->credentials));
|
||||
$baseConfig = config('filesystems.disks.'.$disk->driver, []);
|
||||
|
||||
foreach ($baseConfig as $key => $value) {
|
||||
if ($credentials->has($key)) {
|
||||
$baseConfig[$key] = $credentials[$key];
|
||||
}
|
||||
}
|
||||
|
||||
config(['filesystems.disks.'.$diskName => $baseConfig]);
|
||||
config(['media-library.disk_name' => $diskName]);
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
// DB not yet migrated or settings table missing — use config default
|
||||
|
||||
Reference in New Issue
Block a user