Skip to content

Commit

Permalink
Don't call function_exists() every time debug is set.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
markstory committed May 16, 2014
1 parent 603b537 commit 13a9942
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions src/Core/Configure.php
Expand Up @@ -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.
*
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 13a9942

Please sign in to comment.