From 0c8e1b6256941bbdff141b966d9d25e518e3b2fe Mon Sep 17 00:00:00 2001 From: Jun Pataleta Date: Wed, 7 May 2025 18:07:33 +0800 Subject: [PATCH] MDL-85193 course: Fix restore of backups with missing activity plugins Show debugging instead of throwing an error when fetching an activity icon from a missing activity plugin. --- course/classes/output/activity_icon.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/course/classes/output/activity_icon.php b/course/classes/output/activity_icon.php index 6c0690b4de0..f9e878cab01 100644 --- a/course/classes/output/activity_icon.php +++ b/course/classes/output/activity_icon.php @@ -17,6 +17,7 @@ namespace core_course\output; use core\component; +use core\exception\coding_exception; use core\output\local\properties\iconsize; use core\output\renderable; use core\output\renderer_base; @@ -63,7 +64,12 @@ class activity_icon implements renderable, templatable { /** @var string the module name */ protected string $modname, ) { - $this->isbranded = component_callback('mod_' . $this->modname, 'is_branded', [], false) ? true : false; + try { + $this->isbranded = component_callback('mod_' . $this->modname, 'is_branded', [], false); + } catch (coding_exception $e) { + debugging($e->getMessage(), DEBUG_DEVELOPER); + $this->isbranded = false; + } $this->purpose = plugin_supports('mod', $this->modname, FEATURE_MOD_PURPOSE, MOD_PURPOSE_OTHER); }