Config::ini_set(): fix detecting errors

This commit is contained in:
Benjamin Renard 2024-12-13 15:55:55 +01:00
parent e8cb6a0343
commit 8f90854f0f
Signed by: bn8
GPG key ID: 3E2E1CE1907115BC

View file

@ -246,11 +246,13 @@ Class Config {
*/
public static function ini_set($option, $value) {
Log :: trace('Set PHP INI option "%s" to "%s"', $option, $value);
if (ini_set($option, $value) === false)
// ini_set() return the old value in case of success or false in case of error. If option is
// unset, ini_set() will also return false. To detect error, compare set value with value
// retrieve after using ini_get().
ini_set($option, $value);
$new_value = ini_get($option);
if ($new_value !== $value)
Log::warning('Fail to set PHP INI option "%s" to "%s"', $option, $value);
Log :: trace(
'PHP INI option "%s" after setting it to "%s": "%s"',
$option, $value, vardump(ini_get($option)));
}
}