mirror of
https://github.com/moodle/moodle.git
synced 2025-08-08 02:16:41 +02:00
MDL-82688 filter_data: Handle courseid when no category
This is a regression from a refactor made as a part of 82427.
This commit is contained in:
parent
8a6e8563fd
commit
cecd4ecbf4
1 changed files with 5 additions and 2 deletions
|
@ -15,6 +15,7 @@
|
||||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
namespace filter_data;
|
namespace filter_data;
|
||||||
|
|
||||||
use core_filters\filter_object;
|
use core_filters\filter_object;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -38,9 +39,11 @@ class text_filter extends \core_filters\text_filter {
|
||||||
static $nothingtodo;
|
static $nothingtodo;
|
||||||
|
|
||||||
// Try to get current course.
|
// 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.
|
// 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) {
|
if ($cacheduserid !== $USER->id) {
|
||||||
// Invalidate all caches if the user changed.
|
// Invalidate all caches if the user changed.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue