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 | |
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
-rw-r--r-- | apps/files/appinfo/update.php | 9 | ||||
-rw-r--r-- | apps/files/appinfo/version | 2 | ||||
-rw-r--r-- | config/config.sample.php | 14 | ||||
-rw-r--r-- | core/js/config.php | 2 | ||||
-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 |
8 files changed, 28 insertions, 22 deletions
diff --git a/apps/files/appinfo/update.php b/apps/files/appinfo/update.php index 2691c05c348..ff1369bb1a5 100644 --- a/apps/files/appinfo/update.php +++ b/apps/files/appinfo/update.php @@ -94,3 +94,12 @@ if ($installedVersion === '1.1.9' && ( } } } + +/** + * migrate old constant DEBUG to new config value 'debug' + * + * TODO: remove this in ownCloud 8.3 + */ +if(defined('DEBUG') && DEBUG === true) { + \OC::$server->getConfig()->setSystemValue('debug', true); +} diff --git a/apps/files/appinfo/version b/apps/files/appinfo/version index 5ed5faa5f16..9ee1f786d50 100644 --- a/apps/files/appinfo/version +++ b/apps/files/appinfo/version @@ -1 +1 @@ -1.1.10 +1.1.11 diff --git a/config/config.sample.php b/config/config.sample.php index 522cf02ceba..234bf8e0fa3 100644 --- a/config/config.sample.php +++ b/config/config.sample.php @@ -20,12 +20,6 @@ * * use RST syntax */ -/** - * Only enable this for local development and not in production environments - * This will disable the minifier and outputs some additional debug informations - */ -define('DEBUG', true); - $CONFIG = array( @@ -1080,6 +1074,14 @@ $CONFIG = array( 'memcache.locking' => '\\OC\\Memcache\\Redis', /** + * Set this ownCloud instance to debugging mode + * + * Only enable this for local development and not in production environments + * This will disable the minifier and outputs some additional debug information + */ +'debug' => false, + +/** * This entry is just here to show a warning in case somebody copied the sample * configuration. DO NOT ADD THIS SWITCH TO YOUR CONFIGURATION! * diff --git a/core/js/config.php b/core/js/config.php index 95dd7330287..21451bf91b0 100644 --- a/core/js/config.php +++ b/core/js/config.php @@ -62,7 +62,7 @@ if ($defaultExpireDateEnabled) { $outgoingServer2serverShareEnabled = $config->getAppValue('files_sharing', 'outgoing_server2server_share_enabled', 'yes') === 'yes'; $array = array( - "oc_debug" => (defined('DEBUG') && DEBUG) ? 'true' : 'false', + "oc_debug" => $config->getSystemValue('debug', false), "oc_isadmin" => OC_User::isAdminUser(OC_User::getUser()) ? 'true' : 'false', "oc_webroot" => "\"".OC::$WEBROOT."\"", "oc_appswebroots" => str_replace('\\/', '/', json_encode($apps_paths)), // Ugly unescape slashes waiting for better solution 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(); |