From cecd4ecbf4d4cfb06e3dda34e2e7b83499d0c59a Mon Sep 17 00:00:00 2001 From: Andrew Nicols Date: Fri, 2 Aug 2024 19:55:35 +0800 Subject: [PATCH] MDL-82688 filter_data: Handle courseid when no category This is a regression from a refactor made as a part of 82427. --- filter/data/classes/text_filter.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/filter/data/classes/text_filter.php b/filter/data/classes/text_filter.php index 91996c92129..050d2837184 100644 --- a/filter/data/classes/text_filter.php +++ b/filter/data/classes/text_filter.php @@ -15,6 +15,7 @@ // along with Moodle. If not, see . namespace filter_data; + use core_filters\filter_object; /** @@ -38,9 +39,11 @@ class text_filter extends \core_filters\text_filter { static $nothingtodo; // Try to get current course. - $coursectx = $this->context->get_course_context(false); // We could be in a course category so no entries for courseid == 0 will be found. - $courseid = $coursectx?->instanceid ?: 0; + $courseid = 0; + if ($coursectx = $this->context->get_course_context(false)) { + $courseid = $coursectx->instanceid; + } if ($cacheduserid !== $USER->id) { // Invalidate all caches if the user changed.