From 183a4a94c95c5863c215ea397a0fc4be5e4b092e Mon Sep 17 00:00:00 2001 From: Victor Boctor Date: Sat, 20 Oct 2018 21:32:20 -0700 Subject: [PATCH] Fix IssueNoteAddCommand re-assign on feedback The issue was caused by logged in user id being returned as a string. Fixes #24877, #23712 --- core/authentication_api.php | 2 +- core/current_user_api.php | 8 +++++--- core/user_api.php | 18 +++++++++--------- 3 files changed, 15 insertions(+), 13 deletions(-) diff --git a/core/authentication_api.php b/core/authentication_api.php index 376f8a9d08..f69c018dbb 100644 --- a/core/authentication_api.php +++ b/core/authentication_api.php @@ -1078,7 +1078,7 @@ function auth_get_current_user_id() { global $g_cache_current_user_id; if( null !== $g_cache_current_user_id ) { - return $g_cache_current_user_id; + return (int)$g_cache_current_user_id; } $t_cookie_string = auth_get_current_user_cookie(); diff --git a/core/current_user_api.php b/core/current_user_api.php index 1f5f430409..0bc3b82d31 100644 --- a/core/current_user_api.php +++ b/core/current_user_api.php @@ -53,12 +53,14 @@ function current_user_set( $p_user_id ) { global $g_cache_current_user_id; global $g_cache_current_user_pref; - if( $p_user_id == $g_cache_current_user_id ) { - return $p_user_id; + $t_user_id = (int)$p_user_id; + + if( $t_user_id == $g_cache_current_user_id ) { + return $t_user_id; } $t_old_current = $g_cache_current_user_id; - $g_cache_current_user_id = $p_user_id; + $g_cache_current_user_id = $t_user_id; # Clear current user preferences cache $g_cache_current_user_pref = array(); diff --git a/core/user_api.php b/core/user_api.php index fd823d6736..3b57929bbe 100644 --- a/core/user_api.php +++ b/core/user_api.php @@ -502,7 +502,7 @@ function user_get_logged_in_user_ids( $p_session_duration_in_minutes ) { # Get the list of connected users $t_users_connected = array(); while( $t_row = db_fetch_array( $t_result ) ) { - $t_users_connected[] = $t_row['id']; + $t_users_connected[] = (int)$t_row['id']; } return $t_users_connected; @@ -696,7 +696,7 @@ function user_delete( $p_user_id ) { */ function user_get_id_by_name( $p_username, $p_throw = false ) { if( $t_user = user_search_cache( 'username', $p_username ) ) { - return $t_user['id']; + return (int)$t_user['id']; } db_param_push(); @@ -706,7 +706,7 @@ function user_get_id_by_name( $p_username, $p_throw = false ) { $t_row = db_fetch_array( $t_result ); if( $t_row ) { user_cache_database_result( $t_row ); - return $t_row['id']; + return (int)$t_row['id']; } if( $p_throw ) { @@ -728,7 +728,7 @@ function user_get_id_by_name( $p_username, $p_throw = false ) { */ function user_get_id_by_email( $p_email, $p_throw = false ) { if( $t_user = user_search_cache( 'email', $p_email ) ) { - return $t_user['id']; + return (int)$t_user['id']; } db_param_push(); @@ -738,7 +738,7 @@ function user_get_id_by_email( $p_email, $p_throw = false ) { $t_row = db_fetch_array( $t_result ); if( $t_row ) { user_cache_database_result( $t_row ); - return $t_row['id']; + return (int)$t_row['id']; } if( $p_throw ) { @@ -786,7 +786,7 @@ function user_get_enabled_ids_by_email( $p_email ) { */ function user_get_id_by_realname( $p_realname, $p_throw = false ) { if( $t_user = user_search_cache( 'realname', $p_realname ) ) { - return $t_user['id']; + return (int)$t_user['id']; } db_param_push(); @@ -804,7 +804,7 @@ function user_get_id_by_realname( $p_realname, $p_throw = false ) { } user_cache_database_result( $t_row ); - return $t_row['id']; + return (int)$t_row['id']; } /** @@ -817,7 +817,7 @@ function user_get_id_by_realname( $p_realname, $p_throw = false ) { */ function user_get_id_by_user_info( array $p_user, $p_throw_if_id_not_found = false ) { if( isset( $p_user['id'] ) && (int)$p_user['id'] != 0 ) { - $t_user_id = $p_user['id']; + $t_user_id = (int)$p_user['id']; if( $p_throw_if_id_not_found && !user_exists( $t_user_id ) ) { throw new ClientException( sprintf( "User with id '%d' doesn't exist", $t_user_id ), @@ -1333,7 +1333,7 @@ function user_get_unassigned_by_project_id( $p_project_id = null ) { $t_users = array(); while( $t_row = db_fetch_array( $t_result ) ) { - $t_users[] = $t_row['id']; + $t_users[] = (int)$t_row['id']; $t_display[] = user_get_expanded_name_from_row( $t_row ); $t_sort[] = user_get_name_for_sorting_from_row( $t_row ); }