MDL-63690 core_blog: Handle when user blog posts are not being returned
authorMihail Geshoski <mihail@moodle.com>
Wed, 31 Oct 2018 03:44:09 +0000 (11:44 +0800)
committerMihail Geshoski <mihail@moodle.com>
Wed, 31 Oct 2018 03:44:09 +0000 (11:44 +0800)
blog/classes/privacy/provider.php

index 29c9c74..560466b 100644 (file)
@@ -188,10 +188,12 @@ class provider implements
             }, $posts);
             $userlist->add_users($userids);
 
-            // Add any user's who posted on the blog.
-            list($insql, $inparams) = $DB->get_in_or_equal(array_keys($posts), SQL_PARAMS_NAMED);
-            \core_comment\privacy\provider::get_users_in_context_from_sql($userlist, 'c', 'blog', 'format_blog', null, $insql,
+            if (!empty($posts)) {
+                // Add any user's who posted on the blog.
+                list($insql, $inparams) = $DB->get_in_or_equal(array_keys($posts), SQL_PARAMS_NAMED);
+                \core_comment\privacy\provider::get_users_in_context_from_sql($userlist, 'c', 'blog', 'format_blog', null, $insql,
                     $inparams);
+            }
         } else if ($context->contextlevel == CONTEXT_USER) {
             $params = ['userid' => $context->instanceid];