MDL-69704 course: catch exception when calling get_course_content_items

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).
This commit is contained in:
Sara Arjona 2020-10-01 18:48:25 +02:00
parent e049d30613
commit 64fbd346ba

View File

@ -138,8 +138,12 @@ class content_item_service {
// 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);
}
}
}