MDL-47481 Availability: Profile condition error if no users
authorsam marshall <s.marshall@open.ac.uk>
Thu, 2 Oct 2014 09:39:20 +0000 (10:39 +0100)
committersam marshall <s.marshall@open.ac.uk>
Thu, 2 Oct 2014 09:39:20 +0000 (10:39 +0100)
availability/condition/group/classes/condition.php
availability/condition/grouping/classes/condition.php
availability/condition/profile/classes/condition.php

index 3905060..2445cdc 100644 (file)
@@ -176,6 +176,12 @@ class condition extends \core_availability\condition {
     public function filter_user_list(array $users, $not, \core_availability\info $info,
             \core_availability\capability_checker $checker) {
         global $CFG, $DB;
+
+        // If the array is empty already, just return it.
+        if (!$users) {
+            return $users;
+        }
+
         require_once($CFG->libdir . '/grouplib.php');
         $course = $info->get_course();
 
index a538704..e0b5997 100644 (file)
@@ -209,6 +209,11 @@ class condition extends \core_availability\condition {
             \core_availability\capability_checker $checker) {
         global $CFG, $DB;
 
+        // If the array is empty already, just return it.
+        if (!$users) {
+            return $users;
+        }
+
         // List users for this course who match the condition.
         $groupingusers = $DB->get_records_sql("
                 SELECT DISTINCT gm.userid
index 0007e87..59d0617 100644 (file)
@@ -416,6 +416,11 @@ class condition extends \core_availability\condition {
             \core_availability\capability_checker $checker) {
         global $CFG, $DB;
 
+        // If the array is empty already, just return it.
+        if (!$users) {
+            return $users;
+        }
+
         // Get all users from the list who match the condition.
         list ($sql, $params) = $DB->get_in_or_equal(array_keys($users));