MDL-64427 category: Stop error when another user deleting courses
If you try to visit a category where another user is deleting a course the coursecat cache may not be fresh. This is because there is a breif time where the course record will have been deleted, while it is deleting other course information, before the event that triggers the coursecat cache to be purged is fired.
This commit is contained in:
@@ -1582,7 +1582,10 @@ class core_course_category implements renderable, cacheable_object, IteratorAggr
|
||||
}
|
||||
// Prepare the list of core_course_list_element objects.
|
||||
foreach ($ids as $id) {
|
||||
$courses[$id] = new core_course_list_element($records[$id]);
|
||||
// If a course is deleted after we got the cache entry it may not exist in the database anymore.
|
||||
if (!empty($records[$id])) {
|
||||
$courses[$id] = new core_course_list_element($records[$id]);
|
||||
}
|
||||
}
|
||||
}
|
||||
return $courses;
|
||||
@@ -1792,7 +1795,10 @@ class core_course_category implements renderable, cacheable_object, IteratorAggr
|
||||
}
|
||||
// Prepare the list of core_course_list_element objects.
|
||||
foreach ($ids as $id) {
|
||||
$courses[$id] = new core_course_list_element($records[$id]);
|
||||
// If a course is deleted after we got the cache entry it may not exist in the database anymore.
|
||||
if (!empty($records[$id])) {
|
||||
$courses[$id] = new core_course_list_element($records[$id]);
|
||||
}
|
||||
}
|
||||
}
|
||||
return $courses;
|
||||
|
||||
Reference in New Issue
Block a user