diff --git a/framework/core/src/Admin/WhenSavingSettings.php b/framework/core/src/Admin/WhenSavingSettings.php index 4053d0f44c..0eda046a9e 100644 --- a/framework/core/src/Admin/WhenSavingSettings.php +++ b/framework/core/src/Admin/WhenSavingSettings.php @@ -36,14 +36,18 @@ public function beforeSave(Saving $event): void { if (array_key_exists('safe_mode_extensions', $event->settings)) { $safeModeExtensions = json_decode($event->settings['safe_mode_extensions'] ?? '[]', true); + $sorted = []; - $extensions = $this->extensions->getExtensions()->filter(function ($extension) use ($safeModeExtensions) { - return in_array($extension->getId(), $safeModeExtensions); - }); + if ($safeModeExtensions) { + $extensions = $this->extensions->getExtensions()->filter(function ($extension) use ($safeModeExtensions) { + return in_array($extension->getId(), $safeModeExtensions); + }); - $sorted = array_map(fn (Extension $e) => $e->getId(), $this->extensions->sortDependencies($extensions->all())); + $sorted = array_map(fn (Extension $e) => $e->getId(), $this->extensions->sortDependencies($extensions->all())); + $sorted = array_values($sorted); + } - $event->settings['safe_mode_extensions'] = json_encode(array_values($sorted)); + $event->settings['safe_mode_extensions'] = json_encode($sorted); } } diff --git a/framework/core/src/Foundation/Config.php b/framework/core/src/Foundation/Config.php index c2924414ad..4d5efd4a3d 100644 --- a/framework/core/src/Foundation/Config.php +++ b/framework/core/src/Foundation/Config.php @@ -65,7 +65,7 @@ public function maintenanceMode(): string public function safeModeExtensions(): ?array { - return $this->data['safe_mode_extensions']; + return $this->data['safe_mode_extensions'] ?? null; } private function requireKeys(mixed ...$keys): void