From dd7277361b61b45dc3269037a46bc05fbeb83581 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jens=20K=C3=BClzer?= Date: Thu, 10 Sep 2015 13:30:54 +0200 Subject: [PATCH] Fixes bug with debug=1 system setting When you have debug=1 in system settings, manager pages with quip components are broken. This is due to the lines 128-131, which change the set error behaviour of your system (NEVER put out errors to HTML...). The revealing error was the access to config['debugUser'], which may not be set. This throws the error ``` Notice: Undefined index: debugUser in /core/components/quip/model/quip/quip.class.php on line 132 ``` This error was already reported at http://bugs.modx.com/issues/8467 and on other places, but was never corrected. --- .../components/quip/model/quip/quip.class.php | 22 ++++++++++++++----- 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/core/components/quip/model/quip/quip.class.php b/core/components/quip/model/quip/quip.class.php index b64ce61..c17c74b 100644 --- a/core/components/quip/model/quip/quip.class.php +++ b/core/components/quip/model/quip/quip.class.php @@ -125,11 +125,21 @@ function __construct(modX &$modx,array $config = array()) { */ public function initDebug() { if ($this->modx->getOption('debug',$this->config,false)) { - error_reporting(E_ALL); ini_set('display_errors',true); - $this->modx->setLogTarget('HTML'); - $this->modx->setLogLevel(modX::LOG_LEVEL_ERROR); - - $debugUser = $this->config['debugUser'] == '' ? $this->modx->user->get('username') : 'anonymous'; + //error_reporting(E_ALL); + //ini_set('display_errors',true); + //$this->modx->setLogTarget('HTML'); + //$this->modx->setLogLevel(modX::LOG_LEVEL_ERROR); + + /* BUG: original code throws an error, when debugUser has not been set. Together with the (wrong) error + reporting settings above this caused the manager to be unusable in debug mode + */ + $debugUser = 'anonymous'; + if (isset($this->config['debugUser'])) { + if ($this->config['debugUser'] == '') { + $debugUser = $this->modx->user->get('username'); + } + } + $user = $this->modx->getObject('modUser',array('username' => $debugUser)); if ($user == null) { $this->modx->user->set('id',$this->modx->getOption('debugUserId',$this->config,1)); @@ -504,4 +514,4 @@ public function loadController($controller) { } return $this->controller; } -} \ No newline at end of file +}