Commit 49db6749 authored by Jenkins's avatar Jenkins
Browse files

Merge branch 'MDL-71835' of git://github.com/paulholden/moodle into master_precheck

parents dc437b51 91b5e419
......@@ -108,31 +108,30 @@ class report_log_table_log extends table_sql {
* @return string|false
*/
protected function get_user_fullname($userid) {
global $DB;
if (empty($userid)) {
return false;
}
if (!empty($this->userfullnames[$userid])) {
return $this->userfullnames[$userid];
// Check if we already have this users' fullname.
$userfullname = $this->userfullnames[$userid] ?? null;
if (!empty($userfullname)) {
return $userfullname;
}
// We already looked for the user and it does not exist.
if ($this->userfullnames[$userid] === false) {
if ($userfullname === false) {
return false;
}
// If we reach that point new users logs have been generated since the last users db query.
list($usql, $uparams) = $DB->get_in_or_equal($userid);
$userfieldsapi = \core_user\fields::for_name();
$sql = "SELECT id," . $userfieldsapi->get_sql('', false, '', '', false)->selects .
" FROM {user} WHERE id " . $usql;
if (!$user = $DB->get_records_sql($sql, $uparams)) {
return false;
$fields = $userfieldsapi->get_sql('', false, '', '', false)->selects;
if ($user = \core_user::get_user($userid, $fields)) {
$this->userfullnames[$userid] = fullname($user, has_capability('moodle/site:viewfullnames', $this->get_context()));
} else {
$this->userfullnames[$userid] = false;
}
$this->userfullnames[$userid] = fullname($user, has_capability('moodle/site:viewfullnames', $this->get_context()));
return $this->userfullnames[$userid];
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment