mirror of
https://github.com/moodle/moodle.git
synced 2025-03-19 15:10:05 +01:00
Merge branch 'MDL-43421' of git://github.com/mr-russ/moodle
This commit is contained in:
commit
b646a710ba
@ -1700,7 +1700,19 @@ function user_accesstime_log($courseid=0) {
|
||||
$last->userid = $USER->id;
|
||||
$last->courseid = $courseid;
|
||||
$last->timeaccess = $timenow;
|
||||
$DB->insert_record_raw('user_lastaccess', $last, false);
|
||||
try {
|
||||
$DB->insert_record_raw('user_lastaccess', $last, false);
|
||||
} catch (dml_write_exception $e) {
|
||||
// During a race condition we can fail to find the data, then it appears.
|
||||
// If we still can't find it, rethrow the exception.
|
||||
$lastaccess = $DB->get_field('user_lastaccess', 'timeaccess', array('userid' => $USER->id,
|
||||
'courseid' => $courseid));
|
||||
if ($lastaccess === false) {
|
||||
throw $e;
|
||||
}
|
||||
// If we did find it, the race condition was true and another thread has inserted the time for us.
|
||||
// We can just continue without having to do anything.
|
||||
}
|
||||
|
||||
} else if ($timenow - $lastaccess < LASTACCESS_UPDATE_SECS) {
|
||||
// no need to update now, it was updated recently in concurrent login ;-)
|
||||
|
Loading…
x
Reference in New Issue
Block a user