Commit 7289f5c0 authored by Neill Magill's avatar Neill Magill
Browse files

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.
parent 236a52c4
......@@ -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;
......
Supports Markdown
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