MDL-69962 tool_usertours: Fix increase in included files
authorKatie Ransom <katie.ransom@open.ac.uk>
Mon, 19 Oct 2020 09:45:26 +0000 (10:45 +0100)
committerKatie Ransom <katie.ransom@open.ac.uk>
Mon, 19 Oct 2020 09:45:26 +0000 (10:45 +0100)
admin/tool/usertours/classes/manager.php

index 437b416..9d76b2e 100644 (file)
@@ -637,11 +637,13 @@ class manager {
         $tours = cache::get_matching_tourdata($pageurl);
 
         $matches = [];
-        $filters = helper::get_all_filters();
-        foreach ($tours as $record) {
-            $tour = tour::load_from_record($record);
-            if ($tour->is_enabled() && $tour->matches_all_filters($PAGE->context, $filters)) {
-                $matches[] = $tour;
+        if ($tours) {
+            $filters = helper::get_all_filters();
+            foreach ($tours as $record) {
+                $tour = tour::load_from_record($record);
+                if ($tour->is_enabled() && $tour->matches_all_filters($PAGE->context, $filters)) {
+                    $matches[] = $tour;
+                }
             }
         }