From 40d7c05362a9d53132e7c550ca4b6b40d36b2489 Mon Sep 17 00:00:00 2001 From: Simon L Date: Mon, 13 Nov 2023 15:39:55 +0100 Subject: [PATCH] add JSON_THROW_ON_ERROR to json_encode and json_decode in config manager Signed-off-by: Simon L --- php/src/Data/ConfigurationManager.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/php/src/Data/ConfigurationManager.php b/php/src/Data/ConfigurationManager.php index f23cfcdaa2f..c72e16414d4 100644 --- a/php/src/Data/ConfigurationManager.php +++ b/php/src/Data/ConfigurationManager.php @@ -12,7 +12,7 @@ public function GetConfig() : array if(file_exists(DataConst::GetConfigFile())) { $configContent = file_get_contents(DataConst::GetConfigFile()); - return json_decode($configContent, true); + return json_decode($configContent, true, 512, JSON_THROW_ON_ERROR); } return []; @@ -514,7 +514,7 @@ public function WriteConfig(array $config) : void { throw new InvalidSettingConfigurationException(DataConst::GetDataDirectory() . " does not exist! Something was set up falsely!"); } $df = disk_free_space(DataConst::GetDataDirectory()); - $content = json_encode($config, JSON_UNESCAPED_SLASHES|JSON_PRETTY_PRINT); + $content = json_encode($config, JSON_UNESCAPED_SLASHES|JSON_PRETTY_PRINT|JSON_THROW_ON_ERROR); $size = strlen($content) + 10240; if ($df !== false && (int)$df < $size) { throw new InvalidSettingConfigurationException(DataConst::GetDataDirectory() . " does not have enough space for writing the config file! Not writing it back!");