diff options
author | Morris Jobke <hey@morrisjobke.de> | 2015-08-24 12:00:37 +0200 |
---|---|---|
committer | Morris Jobke <hey@morrisjobke.de> | 2015-08-24 15:14:05 +0200 |
commit | e88b380973b54bc7b8bc86f888b1f11ae8e54076 (patch) | |
tree | eb26a996febd377d21d756fdddd884a1a2ea451d /lib | |
parent | a67a2272e77485391695af84644e7a9074e50af8 (diff) | |
download | nextcloud-server-e88b380973b54bc7b8bc86f888b1f11ae8e54076.tar.gz nextcloud-server-e88b380973b54bc7b8bc86f888b1f11ae8e54076.zip |
Remove DEBUG constant and use config value
* introduces config.php option 'debug' that defaults to false
* migrate DEBUG constant to config value
Diffstat (limited to 'lib')
-rw-r--r-- | lib/base.php | 9 | ||||
-rw-r--r-- | lib/private/config.php | 6 | ||||
-rw-r--r-- | lib/private/server.php | 6 | ||||
-rw-r--r-- | lib/private/template.php | 2 |
4 files changed, 9 insertions, 14 deletions
diff --git a/lib/base.php b/lib/base.php index 2435661dfa6..aceac2e53c3 100644 --- a/lib/base.php +++ b/lib/base.php @@ -582,7 +582,7 @@ class OC { if (!defined('PHPUNIT_RUN')) { $logger = \OC::$server->getLogger(); OC\Log\ErrorHandler::setLogger($logger); - if (defined('DEBUG') and DEBUG) { + if (\OC::$server->getConfig()->getSystemValue('debug', false)) { OC\Log\ErrorHandler::register(true); set_exception_handler(array('OC_Template', 'printExceptionErrorPage')); } else { @@ -1040,7 +1040,7 @@ class OC { return false; } - if (defined("DEBUG") && DEBUG) { + if (\OC::$server->getConfig()->getSystemValue('debug', false)) { \OCP\Util::writeLog('core', 'Trying to login from cookie', \OCP\Util::DEBUG); } @@ -1093,11 +1093,12 @@ class OC { self::cleanupLoginTokens($userId); if (!empty($_POST["remember_login"])) { - if (defined("DEBUG") && DEBUG) { + $config = self::$server->getConfig(); + if ($config->getSystemValue('debug', false)) { self::$server->getLogger()->debug('Setting remember login to cookie', array('app' => 'core')); } $token = \OC::$server->getSecureRandom()->getMediumStrengthGenerator()->generate(32); - self::$server->getConfig()->setUserValue($userId, 'login_token', $token, time()); + $config->setUserValue($userId, 'login_token', $token, time()); OC_User::setMagicInCookie($userId, $token); } else { OC_User::unsetMagicInCookie(); diff --git a/lib/private/config.php b/lib/private/config.php index 20ff02c1abf..3ad800a00be 100644 --- a/lib/private/config.php +++ b/lib/private/config.php @@ -47,8 +47,6 @@ class Config { protected $configFilePath; /** @var string */ protected $configFileName; - /** @var bool */ - protected $debugMode; /** * @param string $configDir Path to the config dir, needs to end with '/' @@ -59,7 +57,6 @@ class Config { $this->configFilePath = $this->configDir.$fileName; $this->configFileName = $fileName; $this->readData(); - $this->debugMode = (defined('DEBUG') && DEBUG); } /** @@ -225,9 +222,6 @@ class Config { private function writeData() { // Create a php file ... $content = "<?php\n"; - if ($this->debugMode) { - $content .= "define('DEBUG',true);\n"; - } $content .= '$CONFIG = '; $content .= var_export($this->cache, true); $content .= ";\n"; diff --git a/lib/private/server.php b/lib/private/server.php index 92a671c721d..5a3a6328fae 100644 --- a/lib/private/server.php +++ b/lib/private/server.php @@ -329,14 +329,14 @@ class Server extends SimpleContainer implements IServerContainer { ); }); $this->registerService('EventLogger', function (Server $c) { - if (defined('DEBUG') and DEBUG) { + if ($c->getSystemConfig()->getValue('debug', false)) { return new EventLogger(); } else { return new NullEventLogger(); } }); - $this->registerService('QueryLogger', function ($c) { - if (defined('DEBUG') and DEBUG) { + $this->registerService('QueryLogger', function (Server $c) { + if ($c->getSystemConfig()->getValue('debug', false)) { return new QueryLogger(); } else { return new NullQueryLogger(); diff --git a/lib/private/template.php b/lib/private/template.php index e7acc778de3..920be71abbf 100644 --- a/lib/private/template.php +++ b/lib/private/template.php @@ -233,7 +233,7 @@ class OC_Template extends \OC\Template\Base { $content->assign('file', $exception->getFile()); $content->assign('line', $exception->getLine()); $content->assign('trace', $exception->getTraceAsString()); - $content->assign('debugMode', defined('DEBUG') && DEBUG === true); + $content->assign('debugMode', \OC::$server->getSystemConfig()->getValue('debug', false)); $content->assign('remoteAddr', $request->getRemoteAddress()); $content->assign('requestID', $request->getId()); $content->printPage(); |