diff --git a/src/Core/Configure.php b/src/Core/Configure.php index d2aebc7e031..5bc13cde1c7 100644 --- a/src/Core/Configure.php +++ b/src/Core/Configure.php @@ -48,6 +48,13 @@ class Configure { */ protected static $_engines = []; +/** + * Flag to track whether or not ini_set exists. + * + * @return void + */ + protected static $_hasIniSet = null; + /** * Used to store a dynamic variable in Configure. * @@ -81,11 +88,12 @@ public static function write($config, $value = null) { static::$_values = Hash::insert(static::$_values, $name, $value); } - if (isset($config['debug']) && function_exists('ini_set')) { - if (static::$_values['debug']) { - ini_set('display_errors', 1); - } else { - ini_set('display_errors', 0); + if (isset($config['debug'])) { + if (static::$_hasIniSet === null) { + static::$_hasIniSet = function_exists('ini_set'); + } + if (static::$_hasIniSet) { + ini_set('display_errors', $config['debug'] ? 1 : 0); } } return true;