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

Multiple unnecessary Messaging AJAX requests (core_message_get_unread_conversations_count, message_popup_get_unread_popup_notification_count) on all pages

    XMLWordPrintable

    Details

    • Testing Instructions:
      Hide
      Prerequisites
      1. You need to purge all the caches before the test.
      2. You need to have access as admin.
      3. You need to know how to use Network Console on the Browser to debug the AJAX Requests.
      Test
      1. Login as admin
      2. Go to Site administration > Development > Make test course and Create a course with size S.
      3. Go to the new course and create a new Assignment with this Notifications setup:
        • Notify graders about submissions: Yes
        • Default setting for "Notify students": Yes
      1. Go to Participants and enrol Admin user as a teacher.
      2. Then, in the Participants list, pick one student and go to his profile and "Log in as".
      3. Now, you are this student, go to the new course > go to Participants > pick up Admin and send a message to him.
      4. Then, come back to the course and go to the new assignment and Add submission.
      5. Repeat this action with other two students.
      6. Finally, login as admin and enable the Developer Tools on the Browser and go to Network (it depends on the Browser).
      7. Now, you can go to the new course and dashboard and look into Network console (Dev Tools).
      8. Confirm you don't have AJAX requests to:

      YOURMOODLEDOMAIN/lib/ajax/service.php?sesskey=YOURSESSION&info=core_message_get_unread_conversations_count
      YOURMOODLEDOMAIN/lib/ajax/service.php?sesskey=YOURSESSION&info=message_popup_get_unread_popup_notification_count

      Exected results
      1. Confirm you have messages to unread and notifications to unread.
      2. Confirm you can open the popup notifications and messages and when you close the popup without pick any notification or message, the unread messages and notifications will be displayed.
      3. Confirm you can open the popup notification and pick up one of the unread notifications and then the new unread count notifications has a minus one unread count notifications.
      4. Confirm you can open the popup messages and pick up one of the unread messages and then the new unread count messages has a minus one unread count messages.
      Show
      Prerequisites You need to purge all the caches before the test. You need to have access as admin. You need to know how to use Network Console on the Browser to debug the AJAX Requests. Test Login as admin Go to Site administration > Development > Make test course and Create a course with size S. Go to the new course and create a new Assignment with this Notifications setup: Notify graders about submissions: Yes Default setting for "Notify students": Yes Go to Participants and enrol Admin user as a teacher. Then, in the Participants list, pick one student and go to his profile and "Log in as". Now, you are this student, go to the new course > go to Participants > pick up Admin and send a message to him. Then, come back to the course and go to the new assignment and Add submission. Repeat this action with other two students. Finally, login as admin and enable the Developer Tools on the Browser and go to Network (it depends on the Browser). Now, you can go to the new course and dashboard and look into Network console (Dev Tools). Confirm you don't have AJAX requests to: YOURMOODLEDOMAIN/lib/ajax/service.php?sesskey=YOURSESSION&info=core_message_get_unread_conversations_count YOURMOODLEDOMAIN/lib/ajax/service.php?sesskey=YOURSESSION&info=message_popup_get_unread_popup_notification_count Exected results Confirm you have messages to unread and notifications to unread. Confirm you can open the popup notifications and messages and when you close the popup without pick any notification or message, the unread messages and notifications will be displayed. Confirm you can open the popup notification and pick up one of the unread notifications and then the new unread count notifications has a minus one unread count notifications. Confirm you can open the popup messages and pick up one of the unread messages and then the new unread count messages has a minus one unread count messages.
    • Affected Branches:
      MOODLE_31_STABLE, MOODLE_33_STABLE, MOODLE_34_STABLE, MOODLE_35_STABLE, MOODLE_36_STABLE
    • Fixed Branches:
      MOODLE_34_STABLE, MOODLE_35_STABLE
    • Pull 3.5 Branch:
    • Pull Master Branch:
      MDL-57968-master

      Description

      Since Moodle 3.1, Moodle makes an AJAX request to core_fetch_notifications on all pages. This seems unnecessary, since all it does is load notifications from the session; it's unlikely that notifications would be added between when the page loads and when this AJAX request is triggered (immediately).

      For example, supposing a server receives 20 requests for normal PHP pages per second under Moodle 3.0 (with messaging turned off), this increases to approximately 40 in Moodle 3.1. Or from 40 to 60 with messaging turned on. While these extra requests are probably easy to handle, it's still additional load, additional log entries, etc. and given there is almost no benefit for the cost, this seems like a performance bug.

      I discussed this in developer chat:

      Dan Poltawski, [14.02.17 12:15]
      I think its worth an issue about that one yes. I can't think of a reason why we need to do a poll for those notifications

      Andrew Nicols, [14.02.17 12:33]
      The original reason was to allow for notifications that are pushed after footer. But realistically it's an edge case
      Andrew Nicols, [14.02.17 12:33]
      It was discussed when it was integrated.

      The mechanism for this is that lib/outputrenderers.php, function footer() calls $this->page->requires->js_call_amd('core/notification', 'init', ...) which is in lib/amd/src/notifications.js; the last thing this function does is notificationModule.fetchNotifications() which makes the AJAX call.

      So anyway - I think this is probably a performance bug (it would be preferable to disallow notifications after calling the footer, rather than to make all these extra AJAX requests), but it may be debatable...

        Attachments

          Issue Links

            Activity

              People

              • Votes:
                14 Vote for this issue
                Watchers:
                26 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Fix Release Date:
                  9/Jul/18

                  Time Tracking

                  Estimated:
                  Original Estimate - 0 minutes
                  0m
                  Remaining:
                  Remaining Estimate - 0 minutes
                  0m
                  Logged:
                  Time Spent - 2 hours
                  2h