Merge branch 'MDL-81991-404-alt' of https://github.com/HuongNV13/moodle into MOODLE_404_STABLE

This commit is contained in:
Sara Arjona 2024-07-09 13:07:47 +02:00
commit ba80f884f7
No known key found for this signature in database

View File

@ -979,6 +979,15 @@ function get_user_accessdata($userid, $preloadonly=false) {
$ACCESSLIB_PRIVATE->accessdatabyuser[$USER->id] = $USER->access;
}
// Unfortunately, we can't use the $ACCESSLIB_PRIVATE->dirtyusers array because it is not available in CLI.
// So we need to check if the user has been marked as dirty or not in the cache directly.
// This will add additional queries to the database, but it is the best we can do.
if (CLI_SCRIPT && !empty($ACCESSLIB_PRIVATE->accessdatabyuser[$userid])) {
if (get_cache_flag('accesslib/dirtyusers', $userid, $ACCESSLIB_PRIVATE->accessdatabyuser[$userid]['time'])) {
unset($ACCESSLIB_PRIVATE->accessdatabyuser[$userid]);
}
}
if (!isset($ACCESSLIB_PRIVATE->accessdatabyuser[$userid])) {
if (empty($userid)) {
if (!empty($CFG->notloggedinroleid)) {