-
Bug
-
Resolution: Fixed
-
Critical
-
2.5.2, 2.6.3, 2.7, 2.8.7, 2.9.1, 3.0
-
MOODLE_25_STABLE, MOODLE_26_STABLE, MOODLE_27_STABLE, MOODLE_28_STABLE, MOODLE_29_STABLE, MOODLE_30_STABLE
-
MOODLE_28_STABLE, MOODLE_29_STABLE
-
MDL-42639_master -
core_user_get_users_by_field doesn't return any value if the Web Service user is not an admin or the user you are looking for. core_user_get_users neither.
Both of them (user/externallib.php) rely on user_get_user_details_courses (user/lib.php) and this one on user_get_user_details (user/lib.php).
strong*user_get_user_details*strong on line 268 stated the following condition:
if (($isadmin or $currentuser) and in_array('username', $userfields)) {
$userdetails['username'] = $user->username;
}
So emphasis_username_emphasis is not returned.
In strong*get_users_by_field*strong:
if (!empty($userdetails) and !empty($userdetails[$field])) {
$returnedusers[] = $userdetails;
}
As username was not returned before, the second part of the condition is false so $userdetails is not assigned to $returnedusers and the web service return it empty.
Looking for idnumber differs because in strong*user_get_user_details*strong:
if ($isadmin or $currentuser or in_array('idnumber', $showuseridentityfields)) {
if (in_array('idnumber', $userfields) && $user->idnumber) {
$userdetails['idnumber'] = $user->idnumber;
}
}
The or codition is true if we assign to the web service user the viewuseridentity and to the $CFG->showuseridentity the value idnumber.
- has been marked as being related by
-
MDL-29934 Web service API Roadmap
-
- Closed
-
-
MDL-47783 core_user_get_users does not return user details for normal user accounts
-
- Closed
-
-
MDL-50369 user_get_user_details returns username only to current user or site admin
-
- Closed
-
-
MDL-52908 Fix inconsistencies with 'username' vs department / institution in showuseridentity setting & viewalldetails capability
-
- Closed
-