Skip to content

Commit

Permalink
Fix potential SQL error when logged out
Browse files Browse the repository at this point in the history
  • Loading branch information
samerton committed Apr 24, 2021
1 parent 883f1d3 commit a6d3824
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
4 changes: 2 additions & 2 deletions core/classes/ErrorHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
];
}
Expand Down
4 changes: 4 additions & 0 deletions core/classes/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down
4 changes: 2 additions & 2 deletions error.php
Original file line number Diff line number Diff line change
Expand Up @@ -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/';
}
Expand Down Expand Up @@ -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'),
Expand Down

0 comments on commit a6d3824

Please sign in to comment.