diff --git a/lib/filterlib.php b/lib/filterlib.php
index <HASH>..<HASH> 100644
--- a/lib/filterlib.php
+++ b/lib/filterlib.php
@@ -397,6 +397,8 @@ class legacy_filter extends moodle_text_filter {
         if ($this->courseid) {
             // old filters are called only when inside courses
             return call_user_func($this->filterfunction, $this->courseid, $text);
+        } else {
+            return $text;
         }
     }
 }
"MDL-<I>, legacy_filter should return text even courseid is null, all text in user context will be empty"