From a6d3824d29fb72d7fda14cf9f8536ecb67584070 Mon Sep 17 00:00:00 2001 From: samerton Date: Sat, 24 Apr 2021 14:13:16 +0100 Subject: [PATCH] Fix potential SQL error when logged out --- core/classes/ErrorHandler.php | 4 ++-- core/classes/User.php | 4 ++++ error.php | 4 ++-- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/core/classes/ErrorHandler.php b/core/classes/ErrorHandler.php index d81e91aaa5..b487430f1d 100644 --- a/core/classes/ErrorHandler.php +++ b/core/classes/ErrorHandler.php @@ -76,8 +76,8 @@ private static function parseFrame($exception, $frame_file, $frame_line, $number 'number' => is_null($number) ? (is_null($exception) ? 1 : count($exception->getTrace()) + 1) : $number, 'file' => $frame_file, 'line' => $frame_line, - 'start_line' => (is_countable($lines) && count($lines) >= self::LINE_BUFFER) ? ($frame_line - self::LINE_BUFFER) : 1, - 'highlight_line' => (is_countable($lines) && count($lines) >= self::LINE_BUFFER) ? (self::LINE_BUFFER + 1) : $frame_line, + 'start_line' => (is_array($lines) && count($lines) >= self::LINE_BUFFER) ? ($frame_line - self::LINE_BUFFER) : 1, + 'highlight_line' => (is_array($lines) && count($lines) >= self::LINE_BUFFER) ? (self::LINE_BUFFER + 1) : $frame_line, 'code' => self::parseFile($lines, $frame_line) ]; } diff --git a/core/classes/User.php b/core/classes/User.php index c88e030d05..08b287b496 100644 --- a/core/classes/User.php +++ b/core/classes/User.php @@ -376,6 +376,10 @@ public function getAllGroups($html = null) { * @return array Array of all their group IDs. */ public function getAllGroupIds() { + if (!$this->isLoggedIn()) { + return array(0); + } + $groups = array(); if (count($this->_groups)) { diff --git a/error.php b/error.php index fefdc84f0c..b87ba835a6 100644 --- a/error.php +++ b/error.php @@ -25,7 +25,7 @@ $user = new User(); if (defined('CONFIG_PATH')) { - $path = CONFIG_PATH . '/core/assets/'; + $path = CONFIG_PATH . '/core/assets/'; } else { $path = '/core/assets/'; } @@ -55,7 +55,7 @@ 'JQUERY' => $jquery, 'PRISM_CSS' => $prism_css, 'PRISM_JS' => $prism_js, - 'DETAILED_ERROR' => $user->isLoggedIn() && $user->hasPermission('admincp.errors'), + 'DETAILED_ERROR' => defined('DEBUGGING') || ($user->isLoggedIn() && $user->hasPermission('admincp.errors')), 'FATAL_ERROR_TITLE' => $language->get('errors', 'fatal_error_title'), 'FATAL_ERROR_MESSAGE_ADMIN' => $language->get('errors', 'fatal_error_message_admin'), 'FATAL_ERROR_MESSAGE_USER' => $language->get('errors', 'fatal_error_message_user'),