Skip to content

Commit

Permalink
Remove call to project_includes_user
Browse files Browse the repository at this point in the history
project_includes_user() is called once for every user that is displayed
in project manage page, to check if user is directly assigned to the
project and print the "remove" button.  This function performs a db
query for each user, which degrades performance as user count grows, and
is especilally severe on public projects.

Instead, fetch all local user at once and compare against the saved
array if user is directly assigned to the project.

Fixes #20242
  • Loading branch information
cproensa authored and dregad committed Mar 7, 2016
1 parent bb84876 commit b499d5c
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion manage_proj_edit_page.php
Expand Up @@ -572,6 +572,12 @@
$t_users_count = count( $t_sort );
$t_removable_users_exist = false;

# If including global users, fetch here all local user to later distinguish them
$t_local_users = array();
if( $f_show_global_users ) {
$t_local_users = project_get_all_user_rows( $f_project_id, ANYBODY, false );
}

for( $i = 0; $i < $t_users_count; $i++ ) {
$t_user = $t_users[$i];
?>
Expand All @@ -592,7 +598,7 @@
# You need global or project-specific permissions to remove users
# from this project
if( $t_can_manage_users && access_has_project_level( $t_user['access_level'], $f_project_id ) ) {
if( project_includes_user( $f_project_id, $t_user['id'] ) ) {
if( !$f_show_global_users || $f_show_global_users && isset( $t_local_users[$t_user['id']]) ) {
print_button( 'manage_proj_user_remove.php?project_id=' . $f_project_id . '&user_id=' . $t_user['id'], lang_get( 'remove_link' ) );
$t_removable_users_exist = true;
}
Expand Down

0 comments on commit b499d5c

Please sign in to comment.