add JSON_THROW_ON_ERROR to json_encode and json_decode in config manager

Signed-off-by: Simon L <szaimen@e.mail.de>
This commit is contained in:
Simon L 2023-11-13 15:39:55 +01:00
parent 85933dd149
commit 40d7c05362

View file

@ -12,7 +12,7 @@ class ConfigurationManager
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 @@ class ConfigurationManager
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!");