Skip to content

Commit

Permalink
MDL-69704 course: catch exception when calling get_course_content_items
Browse files Browse the repository at this point in the history
When plugins are removed from disk, an exception is thrown when
calling component_callback_exists.
This exception should be catched here in order to load properly
the activity chooser (otherwise, the exception will be displayed
and no activity will appear).
  • Loading branch information
sarjona committed Oct 1, 2020
1 parent 8b02680 commit d12c140
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions course/classes/local/service/content_item_service.php
Expand Up @@ -138,8 +138,12 @@ private function get_content_favourites(string $prefix, \context_user $userconte
// Add any subplugins to the list of item types.
$subplugins = $pluginmanager->get_subplugins_of_plugin('mod_' . $plugin->name);
foreach ($subplugins as $subpluginname => $subplugininfo) {
if (component_callback_exists($subpluginname, 'get_course_content_items')) {
$itemtypes[] = $prefix . $subpluginname;
try {
if (component_callback_exists($subpluginname, 'get_course_content_items')) {
$itemtypes[] = $prefix . $subpluginname;
}
} catch (\moodle_exception $e) {
debugging('Cannot get_course_content_items: ' . $e->getMessage(), DEBUG_DEVELOPER);
}
}
}
Expand Down

0 comments on commit d12c140

Please sign in to comment.