diff options
| author | Jan-Hendrik Willms <tleilax+studip@gmail.com> | 2023-07-03 08:15:36 +0000 |
|---|---|---|
| committer | David Siegfried <david.siegfried@uni-vechta.de> | 2023-07-03 08:15:36 +0000 |
| commit | 3d6e9f573c39cadc3af2f3eff89eee2c4af68b34 (patch) | |
| tree | aedd856e484c2d5f90fe5f1b52a2b5e2d522e22d /lib/functions.php | |
| parent | 9a720a69d9052a865163054c133b916782a8c529 (diff) | |
fix errors and warnings, fixes #2803
Closes #2803
Merge request studip/studip!1890
Diffstat (limited to 'lib/functions.php')
| -rw-r--r-- | lib/functions.php | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/lib/functions.php b/lib/functions.php index 144b6f5..20066c1 100644 --- a/lib/functions.php +++ b/lib/functions.php @@ -302,21 +302,22 @@ function my_substr($what, $start, $end) */ function get_fullname($user_id = "", $format = "full" , $htmlready = false) { - static $cache; - global $user, $_fullname_sql; + static $cache = []; + + $current_user = User::findCurrent(); if (!$user_id) { - $user_id = $user->id; + $user_id = $current_user ? $current_user->id : null; } - if (User::findCurrent()->id === $user_id) { - $fullname = User::findCurrent()->getFullName($format); + if ($current_user && $current_user->id === $user_id) { + $fullname = $current_user->getFullName($format); return $htmlready ? htmlReady($fullname) : $fullname; } $hash = md5($user_id . $format); if (!isset($cache[$hash])) { - $query = "SELECT {$_fullname_sql[$format]} + $query = "SELECT {$GLOBALS['_fullname_sql'][$format]} FROM auth_user_md5 LEFT JOIN user_info USING (user_id) WHERE user_id = ?"; |
