Skip to content

Commit

Permalink
Fix IssueNoteAddCommand re-assign on feedback
Browse files Browse the repository at this point in the history
The issue was caused by logged in user id being returned as a string.

Fixes #24877, #23712
  • Loading branch information
vboctor committed Oct 29, 2018
1 parent e80d426 commit 183a4a9
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 13 deletions.
2 changes: 1 addition & 1 deletion core/authentication_api.php
Expand Up @@ -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();
Expand Down
8 changes: 5 additions & 3 deletions core/current_user_api.php
Expand Up @@ -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();
Expand Down
18 changes: 9 additions & 9 deletions core/user_api.php
Expand Up @@ -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;
Expand Down Expand Up @@ -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();
Expand All @@ -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 ) {
Expand All @@ -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();
Expand All @@ -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 ) {
Expand Down Expand Up @@ -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();
Expand All @@ -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'];
}

/**
Expand All @@ -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 ),
Expand Down Expand Up @@ -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 );
}
Expand Down

0 comments on commit 183a4a9

Please sign in to comment.