Skip to content

Commit 13a9942

Browse files
committed
Don't call function_exists() every time debug is set.
Only call function_exists() the first time debug is called. This saves a few calls to function exists over the span of a test suite run.
1 parent 603b537 commit 13a9942

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

src/Core/Configure.php

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,13 @@ class Configure {
4848
*/
4949
protected static $_engines = [];
5050

51+
/**
52+
* Flag to track whether or not ini_set exists.
53+
*
54+
* @return void
55+
*/
56+
protected static $_hasIniSet = null;
57+
5158
/**
5259
* Used to store a dynamic variable in Configure.
5360
*
@@ -81,11 +88,12 @@ public static function write($config, $value = null) {
8188
static::$_values = Hash::insert(static::$_values, $name, $value);
8289
}
8390

84-
if (isset($config['debug']) && function_exists('ini_set')) {
85-
if (static::$_values['debug']) {
86-
ini_set('display_errors', 1);
87-
} else {
88-
ini_set('display_errors', 0);
91+
if (isset($config['debug'])) {
92+
if (static::$_hasIniSet === null) {
93+
static::$_hasIniSet = function_exists('ini_set');
94+
}
95+
if (static::$_hasIniSet) {
96+
ini_set('display_errors', $config['debug'] ? 1 : 0);
8997
}
9098
}
9199
return true;

0 commit comments

Comments
 (0)