Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-39947

PHP Notice when counting unread forum posts

    XMLWordPrintable

    Details

    • Testing Instructions:
      Hide
      1. Login as admin
      2. Enrol 2 students to the course (s1, s2)
      3. Create 1 group, and 1 grouping in the course
        • The group contains both students
        • The grouping contains the group 1
      4. Create a forum with
        • Tracking enabled
        • Separate groups
        • Grouping set to A
      5. Login as both students and enable forum tracking in your preference
      6. Login as s1 and post to the forum
      7. Login as s2 and make sure you see the number of unread posts (1) in the course page
      8. Login as admin and delete the grouping A
      9. Login back as s2
      10. Make sure you see the number of unread posts
      11. Make sure you don't see any notice
      Show
      Login as admin Enrol 2 students to the course (s1, s2) Create 1 group, and 1 grouping in the course The group contains both students The grouping contains the group 1 Create a forum with Tracking enabled Separate groups Grouping set to A Login as both students and enable forum tracking in your preference Login as s1 and post to the forum Login as s2 and make sure you see the number of unread posts (1) in the course page Login as admin and delete the grouping A Login back as s2 Make sure you see the number of unread posts Make sure you don't see any notice
    • Affected Branches:
      MOODLE_23_STABLE, MOODLE_24_STABLE, MOODLE_25_STABLE
    • Fixed Branches:
      MOODLE_23_STABLE, MOODLE_24_STABLE, MOODLE_25_STABLE
    • Pull from Repository:
    • Pull Master Branch:

      Description

      Due to a bug in the forum_tp_count_forum_unread_posts() function, for some users in some forum discussions, it's possible for the function to trigger a large amount of php notices.

      This is due to the following line assuming an array element exists:

      $mygroups = $modinfo->groups[$cm->groupingid];
      

      This same assignment occurs earlier in the forum/lib.php file, but has protection like so:

          if (array_key_exists($cm->groupingid, $modinfo->groups)) {
              $mygroups = $modinfo->groups[$cm->groupingid];
          } else {
              $mygroups = false; // Will be set below
          }
      

      My proposed solution is to use this same checking & assignment as it achieves the same result and fixes the bug.

        Attachments

          Issue Links

            Activity

              People

              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Fix Release Date:
                  8/Jul/13