mirror of
https://github.com/moodle/moodle.git
synced 2025-04-22 17:02:03 +02:00
MDL-72704 message: Additional optimisation tweaks
* Return early if the `userids` params is empty or if the filtered user IDs end up being empty.
This commit is contained in:
parent
7e2931d7d3
commit
9cd200777e
@ -3396,6 +3396,11 @@ class core_message_external extends external_api {
|
||||
throw new moodle_exception('You do not have permission to perform this action.');
|
||||
}
|
||||
|
||||
// Return early if no userids are provided.
|
||||
if (empty($params['userids'])) {
|
||||
return [];
|
||||
}
|
||||
|
||||
// Filter the user IDs, removing the IDs of the users that the current user cannot view.
|
||||
require_once($CFG->dirroot . '/user/lib.php');
|
||||
$userfieldsapi = \core_user\fields::for_userpic()->including('username', 'deleted');
|
||||
@ -3406,9 +3411,14 @@ class core_message_external extends external_api {
|
||||
return user_can_view_profile($targetuser);
|
||||
});
|
||||
|
||||
// Return early if no user IDs are left after filtering.
|
||||
if (empty($filteredids)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return \core_message\helper::get_member_info(
|
||||
$params['referenceuserid'],
|
||||
$filteredids ?? [],
|
||||
$filteredids,
|
||||
$params['includecontactrequests'],
|
||||
$params['includeprivacyinfo']
|
||||
);
|
||||
|
Loading…
x
Reference in New Issue
Block a user