MDL-62384 core_rating: Move WHERE clauses to JOIN
authorAndrew Nicols <andrew@nicols.co.uk>
Thu, 10 May 2018 12:19:22 +0000 (20:19 +0800)
committerAndrew Nicols <andrew@nicols.co.uk>
Fri, 11 May 2018 01:15:30 +0000 (09:15 +0800)
rating/classes/privacy/provider.php

index 1bab73b..4237ea2 100644 (file)
@@ -139,12 +139,13 @@ class provider implements
 
         // Join the rating table with the specified alias and the relevant join params.
         $join = "LEFT JOIN {rating} {$alias} ON ";
+        $join .= "{$alias}.userid = :ratinguserid{$count} AND ";
         $join .= "{$alias}.component = :ratingcomponent{$count} AND ";
         $join .= "{$alias}.ratingarea = :ratingarea{$count} AND ";
         $join .= "{$alias}.itemid = {$itemidjoin}";
 
         // Match against the specified user.
-        $userwhere = "{$alias}.userid = :ratinguserid{$count}";
+        $userwhere = "{$alias}.id IS NOT NULL";
 
         $params = [
             'ratingcomponent' . $count  => $component,