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

Email message output tries to send an email even if the user has an empty email address

    • Icon: Improvement Improvement
    • Resolution: Unresolved
    • Icon: Minor Minor
    • None
    • 4.2.6
    • Forum
    • MOODLE_402_STABLE
    • MDL-80484_main
    • Hide

      Steps to reproduce:

      1. Create a user with empty email address field (can be done by creating a user normally and then removing the email address directly from database).
      2. Create a course with forum activity and enrol the new user.
      3. Add a post in forum with forced subscription on.
      4. Go to Site Administration > Server > Scheduled tasks
      5. Find the "Forum mailings and maintenance jobs" task and click "Run Now"
      6. Go to Site Administration > Server > Adhoc tasks
      7. Find the queued "mod_forum\task\send_user_notifications" task and click "Run all"
        • Confirm that the task succeeds, and produces the output "Failed to send emails for the user with id XXX because of empty email address, Skipping re queuing of the task"
      8. Return to Site Administration > Server > Adhoc tasks
        • Confirm there is no queued instance of the "mod_forum\task\send_user_notifications" task
      Show
      Steps to reproduce: Create a user with empty email address field (can be done by creating a user normally and then removing the email address directly from database). Create a course with forum activity and enrol the new user. Add a post in forum with forced subscription on. Go to Site Administration > Server > Scheduled tasks Find the "Forum mailings and maintenance jobs" task and click "Run Now" Go to Site Administration > Server > Adhoc tasks Find the queued "mod_forum\task\send_user_notifications" task and click "Run all" Confirm that the task succeeds, and produces the output "Failed to send emails for the user with id XXX because of empty email address, Skipping re queuing of the task" Return to Site Administration > Server > Adhoc tasks Confirm there is no queued instance of the "mod_forum\task\send_user_notifications" task

      If a user has an empty email address (which can happen if they are added via LDAP sync, as found in MDL-16328) and they are subscribed to a forum, the notification task will repeatedly fail and retry.

      email_to_user() already has a check for empty email addresses and returns false. This false is passed back up the stack to mod_forum\task\send_user_notifications where it is treated as an error, and the task is re-queued even though it will not work the subsequent times unless the user is updated, so will be re-queued indefinitely.

      We should handle the case where a user has no email, and skip re-queuing the message in this case, with some output to indicate this has happened.

      Steps to reproduce:

      1. Create a user with empty email address field (can be done by creating a user normally and then removing the email address directly from database).
      2. Create a course with forum activity and enrol the new user.
      3. Add a post in forum with forced subscription on.
      4. Run the Forum mailings and maintenance jobs scheduled task.
      5. Run the mod_forum\task\send_user_notifications adhoc task.
      6. It should fail because of empty email address and then be re queued this can be confirmed by checking the adhoc database table. 
        Expected: The task should not be re queued after failing because of an empty email address.
        Actual: The task is re queued even if it fails because of empty email address

       

            Unassigned Unassigned
            marxjohnson Mark Johnson
            Mark Johnson Mark Johnson
            Mihail Geshoski Mihail Geshoski
            Votes:
            3 Vote for this issue
            Watchers:
            11 Start watching this issue

              Created:
              Updated:

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 2 hours, 37 minutes
                2h 37m

                  Error rendering 'clockify-timesheets-time-tracking-reports:timer-sidebar'. Please contact your Jira administrators.