MDL-63690 core_privacy: Handle when add_users() receives an empty array
authorMihail Geshoski <mihail@moodle.com>
Fri, 26 Oct 2018 01:16:10 +0000 (09:16 +0800)
committerMihail Geshoski <mihail@moodle.com>
Fri, 26 Oct 2018 01:16:10 +0000 (09:16 +0800)
privacy/classes/local/request/userlist.php

index 0664f14..171ccc0 100644 (file)
@@ -80,12 +80,13 @@ class userlist extends userlist_base {
     public function add_users(array $userids) : userlist {
         global $DB;
 
-        list($useridsql, $useridparams) = $DB->get_in_or_equal($userids, SQL_PARAMS_NAMED);
-        $sql = "SELECT DISTINCT u.id
-                  FROM {user} u
-                 WHERE u.id {$useridsql}";
-        $this->add_from_sql('id', $sql, $useridparams);
-
+        if (!empty($userids)) {
+            list($useridsql, $useridparams) = $DB->get_in_or_equal($userids, SQL_PARAMS_NAMED);
+            $sql = "SELECT DISTINCT u.id
+                      FROM {user} u
+                     WHERE u.id {$useridsql}";
+            $this->add_from_sql('id', $sql, $useridparams);
+        }
         return $this;
     }