diff --git a/library/includes/functions.php b/library/includes/functions.php index 1d33da2ca..80e9f1490 100644 --- a/library/includes/functions.php +++ b/library/includes/functions.php @@ -958,7 +958,7 @@ function clean_username($username) } // Get Userdata, $u can be username or user_id. If $force_name is true, the username will be forced. -function get_userdata($u, $force_name = false, $allow_guest = false) +function get_userdata($u, bool $force_name = false, bool $allow_guest = false) { if (!$u) { return false; @@ -970,12 +970,9 @@ function get_userdata($u, $force_name = false, $allow_guest = false) } } - $u_data = array(); - $name_search = false; $exclude_anon_sql = (!$allow_guest) ? "AND user_id != " . GUEST_UID : ''; - if ($force_name || !is_numeric($u)) { - $name_search = true; + if ($force_name || !is_int($u)) { $where_sql = "WHERE username = '" . DB()->escape(clean_username($u)) . "'"; } else { $where_sql = "WHERE user_id = " . (int)$u; @@ -984,11 +981,7 @@ function get_userdata($u, $force_name = false, $allow_guest = false) $sql = "SELECT * FROM " . BB_USERS . " $where_sql $exclude_anon_sql LIMIT 1"; if (!$u_data = DB()->fetch_row($sql)) { - if (!is_int($u) && !$name_search) { - $where_sql = "WHERE username = '" . DB()->escape(clean_username($u)) . "'"; - $sql = "SELECT * FROM " . BB_USERS . " $where_sql $exclude_anon_sql LIMIT 1"; - $u_data = DB()->fetch_row($sql); - } + return false; } if ($u_data['user_id'] == GUEST_UID) {