diff --git a/cake/basics.php b/cake/basics.php index 2403b75bc..0e63fda86 100644 --- a/cake/basics.php +++ b/cake/basics.php @@ -91,7 +91,7 @@ * @link http://book.cakephp.org/view/1128/debug */ function debug($var = false, $showHtml = false, $showFrom = true) { - if (Configure::read() > 0) { + if (Configure::read('debug') > 0) { if ($showFrom) { $calledFrom = debug_backtrace(); echo '' . substr(str_replace(ROOT, '', $calledFrom[0]['file']), 1) . ''; @@ -197,7 +197,7 @@ if (!function_exists('sortByKey')) { * @link http://book.cakephp.org/view/1136/pr */ function pr($var) { - if (Configure::read() > 0) { + if (Configure::read('debug') > 0) { echo '
'; print_r($var); echo ''; diff --git a/cake/libs/configure.php b/cake/libs/configure.php index de12d7bc0..d1c19982c 100644 --- a/cake/libs/configure.php +++ b/cake/libs/configure.php @@ -25,23 +25,16 @@ * @subpackage cake.cake.libs * @link http://book.cakephp.org/view/924/The-Configuration-Class */ -class Configure extends Object { - -/** - * Current debug level. - * - * @link http://book.cakephp.org/view/931/CakePHP-Core-Configuration-Variables - * @var integer - * @access public - */ - public $debug = 0; +class Configure { /** * Array of values currently stored in Configure. * * @var array */ - protected static $_values = array(); + protected static $_values = array( + 'debug' => 0 + ); /** * Initializes configure and runs the bootstrap process. @@ -147,11 +140,13 @@ class Configure extends Object { * @param string $var Variable to obtain. Use '.' to access array elements. * @return string value of Configure::$var */ - public static function read($var = 'debug') { - if ($var === 'debug') { - return self::$_values['debug']; + public static function read($var = null) { + if ($var === null) { + return self::$_values; + } + if (isset(self::$_values[$var])) { + return self::$_values[$var]; } - if (strpos($var, '.') !== false) { $names = explode('.', $var, 3); $var = $names[0]; @@ -159,9 +154,6 @@ class Configure extends Object { if (!isset(self::$_values[$var])) { return null; } - if (!isset($names[1])) { - return self::$_values[$var]; - } switch (count($names)) { case 2: if (isset(self::$_values[$var][$names[1]])) { @@ -315,7 +307,7 @@ class Configure extends Object { private static function __writeConfig($content, $name, $write = true) { $file = CACHE . 'persistent' . DS . $name . '.php'; - if (Configure::read() > 0) { + if (Configure::read('debug') > 0) { $expires = "+10 seconds"; } else { $expires = "+999 days"; @@ -369,7 +361,7 @@ class Configure extends Object { $prefix = $cache['settings']['prefix']; } - if (Configure::read() >= 1) { + if (Configure::read('debug') >= 1) { $duration = '+10 seconds'; } else { $duration = '+999 days'; diff --git a/cake/libs/controller/components/auth.php b/cake/libs/controller/components/auth.php index 01c9d88cc..d70d4797e 100644 --- a/cake/libs/controller/components/auth.php +++ b/cake/libs/controller/components/auth.php @@ -291,7 +291,7 @@ class AuthComponent extends Object { } } $this->_set($settings); - if (Configure::read() > 0) { + if (Configure::read('debug') > 0) { App::import('Debugger'); Debugger::checkSecurityKeys(); } @@ -307,7 +307,7 @@ class AuthComponent extends Object { public function startup(&$controller) { $isErrorOrTests = ( strtolower($controller->name) == 'cakeerror' || - (strtolower($controller->name) == 'tests' && Configure::read() > 0) + (strtolower($controller->name) == 'tests' && Configure::read('debug') > 0) ); if ($isErrorOrTests) { return true; diff --git a/cake/libs/controller/components/request_handler.php b/cake/libs/controller/components/request_handler.php index eedfc80cf..2a9e42ac5 100644 --- a/cake/libs/controller/components/request_handler.php +++ b/cake/libs/controller/components/request_handler.php @@ -718,7 +718,7 @@ class RequestHandlerComponent extends Object { if (!empty($options['attachment'])) { $this->_header("Content-Disposition: attachment; filename=\"{$options['attachment']}\""); } - if (Configure::read() < 2 && !defined('CAKEPHP_SHELL')) { + if (Configure::read('debug') < 2 && !defined('CAKEPHP_SHELL')) { $this->_header($header); } $this->__responseTypeSet = $cType; diff --git a/cake/libs/controller/controller.php b/cake/libs/controller/controller.php index 87cb2c440..0f8bfe189 100644 --- a/cake/libs/controller/controller.php +++ b/cake/libs/controller/controller.php @@ -826,7 +826,7 @@ class Controller extends Object { $this->params['models'] = $this->modelNames; - if (Configure::read() > 2) { + if (Configure::read('debug') > 2) { $this->set('cakeDebug', $this); } diff --git a/cake/libs/debugger.php b/cake/libs/debugger.php index d6b042727..dc9aa2c90 100644 --- a/cake/libs/debugger.php +++ b/cake/libs/debugger.php @@ -181,7 +181,7 @@ class Debugger { if (!empty($class)) { if (!$instance || strtolower($class) != strtolower(get_class($instance[0]))) { $instance[0] = & new $class(); - if (Configure::read() > 0) { + if (Configure::read('debug') > 0) { Configure::version(); // Make sure the core config is loaded $instance[0]->helpPath = Configure::read('Cake.Debugger.HelpPath'); } @@ -190,7 +190,7 @@ class Debugger { if (!$instance) { $instance[0] =& new Debugger(); - if (Configure::read() > 0) { + if (Configure::read('debug') > 0) { Configure::version(); // Make sure the core config is loaded $instance[0]->helpPath = Configure::read('Cake.Debugger.HelpPath'); } diff --git a/cake/libs/model/datasources/dbo/dbo_oracle.php b/cake/libs/model/datasources/dbo/dbo_oracle.php index 708c74250..063a445be 100644 --- a/cake/libs/model/datasources/dbo/dbo_oracle.php +++ b/cake/libs/model/datasources/dbo/dbo_oracle.php @@ -977,7 +977,7 @@ class DboOracle extends DboSource { function queryAssociation(&$model, &$linkModel, $type, $association, $assocData, &$queryData, $external = false, &$resultSet, $recursive, $stack) { if ($query = $this->generateAssociationQuery($model, $linkModel, $type, $association, $assocData, $queryData, $external, $resultSet)) { if (!isset($resultSet) || !is_array($resultSet)) { - if (Configure::read() > 0) { + if (Configure::read('debug') > 0) { echo '