# This patch file was generated by NetBeans IDE
# This patch can be applied using context Tools: Apply Diff Patch action on respective folder.
# It uses platform neutral UTF-8 encoding.
# Above lines and this line are ignored by the patching process.
Index: moodle/rating/lib.php
--- moodle/rating/lib.php Base (1.25)
+++ moodle/rating/lib.php Locally Modified (Based On 1.25)
@@ -503,12 +503,14 @@
             $singleuserwhere = "AND i.{$itemtableusercolumn} = :userid1";
         }
 
-        //note: r.contextid will be null for users who haven't been rated yet
+        //MDL-24648 The where line used to be "WHERE (r.contextid is null or r.contextid=:contextid)"
+        //r.contextid will be null for users who haven't been rated yet
+        //no longer including users who haven't been rated to reduce memory requirements
         $sql = "SELECT u.id as id, u.id AS userid, $aggregationstring(r.rating) AS rawgrade
                 FROM {user} u
                 LEFT JOIN {{$itemtable}} i ON u.id=i.{$itemtableusercolumn}
                 LEFT JOIN {rating} r ON r.itemid=i.id
-                WHERE (r.contextid is null or r.contextid=:contextid)
+                WHERE r.contextid=:contextid
                 $singleuserwhere
                 GROUP BY u.id";
 
