From 647eae08b46f2eb0effb422b1a2fe546a7a397de Mon Sep 17 00:00:00 2001 From: slawkens Date: Sun, 4 Feb 2024 10:10:04 +0100 Subject: [PATCH] Display error message if config.local.php is not writable --- system/settings.php | 7 ++++++- system/src/Settings.php | 6 +++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/system/settings.php b/system/settings.php index 821ddd51..a5d0c00e 100644 --- a/system/settings.php +++ b/system/settings.php @@ -1651,7 +1651,12 @@ Sent by MyAAC,
} } - return Settings::saveConfig($configToSave, BASE . 'config.local.php'); + $success = Settings::saveConfig($configToSave, BASE . 'config.local.php'); + if (!$success) { + error('There has been error saving the config.local.php - probably problem with permissions.'); + } + + return $success; }, ], ]; diff --git a/system/src/Settings.php b/system/src/Settings.php index 91516e34..6c122237 100644 --- a/system/src/Settings.php +++ b/system/src/Settings.php @@ -557,10 +557,10 @@ class Settings implements \ArrayAccess $content .= ';' . PHP_EOL; } - $success = file_put_contents($filename, $content); + $success = @file_put_contents($filename, $content); // we saved new config.php, need to revalidate cache (only if opcache is enabled) - if (function_exists('opcache_invalidate')) { + if ($success && function_exists('opcache_invalidate')) { opcache_invalidate($filename); } @@ -606,7 +606,7 @@ class Settings implements \ArrayAccess return true; } - public function getErrors() { + public function getErrors(): array { return $this->errors; }