Skip to content

Commit

Permalink
fix: setting key safe_mode_extensions not exists
Browse files Browse the repository at this point in the history
  • Loading branch information
datlechin committed May 18, 2024
1 parent 1e7eddb commit 3ebd78d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
14 changes: 9 additions & 5 deletions framework/core/src/Admin/WhenSavingSettings.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand Down
2 changes: 1 addition & 1 deletion framework/core/src/Foundation/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 3ebd78d

Please sign in to comment.