Skip to content

Commit

Permalink
Cache user data when clearing invalid project defaults
Browse files Browse the repository at this point in the history
user_pref_clear_invalid_project_default() can potentially work with a
large number of records, if the project being processed has been set as
default by many users.

Caching all user rows early reduces the overhead, as we execute a single
DB query instead of one per user.

Fixes #28120
  • Loading branch information
dregad committed Apr 4, 2021
1 parent 3426c5e commit f380b96
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions core/user_pref_api.php
Expand Up @@ -563,6 +563,7 @@ function user_pref_clear_invalid_project_default( $p_project_id, array $p_users
$t_users_having_project_as_default = array_column( $t_query->fetch_all(), 'user_id' );

# Users who can't access the project anymore must have the default cleared
user_cache_array_rows( $t_users_having_project_as_default );
$t_users_to_clear = array();
foreach( $t_users_having_project_as_default as $t_id ) {
if( access_get_project_level( $p_project_id, $t_id ) == ANYBODY ) {
Expand Down

0 comments on commit f380b96

Please sign in to comment.