From 64fbd346ba9f60b3a61f795c93bd7c9708f2e67e Mon Sep 17 00:00:00 2001 From: Sara Arjona Date: Thu, 1 Oct 2020 18:48:25 +0200 Subject: [PATCH] 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). --- course/classes/local/service/content_item_service.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/course/classes/local/service/content_item_service.php b/course/classes/local/service/content_item_service.php index 20209ae2d92..ca60efbc146 100644 --- a/course/classes/local/service/content_item_service.php +++ b/course/classes/local/service/content_item_service.php @@ -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); } } } -- 2.43.0