MDL-39947 mod_forum: Add safety check to variable assignment when counting unread...
authorAdam Olley <adam.olley@netspot.com.au>
Thu, 30 May 2013 23:59:56 +0000 (09:29 +0930)
committerAdam Olley <adam.olley@netspot.com.au>
Fri, 31 May 2013 00:15:56 +0000 (09:45 +0930)
mod/forum/lib.php

index 0e3935a..9473987 100644 (file)
@@ -6760,7 +6760,11 @@ function forum_tp_count_forum_unread_posts($cm, $course) {
         $modinfo->groups = groups_get_user_groups($course->id, $USER->id);
     }
 
-    $mygroups = $modinfo->groups[$cm->groupingid];
+    if (array_key_exists($cm->groupingid, $modinfo->groups)) {
+        $mygroups = $modinfo->groups[$cm->groupingid];
+    } else {
+        $mygroups = false; // Will be set below
+    }
 
     // add all groups posts
     if (empty($mygroups)) {