Moodle

Users no longer enrolled in course still receive emails from fourms

Details

  • Type: Sub-task Sub-task
  • Status: Closed Closed
  • Priority: Critical Critical
  • Resolution: Fixed
  • Affects Version/s: 1.8.2, 1.9
  • Fix Version/s: 1.9.1
  • Component/s: Forum
  • Labels:
    None
  • Environment:
    LAMP Server
  • Database:
    MySQL
  • Affected Branches:
    MOODLE_18_STABLE, MOODLE_19_STABLE
  • Fixed Branches:
    MOODLE_19_STABLE

Description

Restored a course from backup. Removed all students. Old students still receiving emails from fourms. Profiles of old students show them as not being enrolled in any class.

Issue Links

Activity

Hide
Martin Dougiamas added a comment - - edited

what about the list of subscribers for the forum? are they in there?

Show
Martin Dougiamas added a comment - - edited what about the list of subscribers for the forum? are they in there?
Hide
Helen Foster added a comment -

Hi Martin,

I've come across this problem on Moodle.org - lots of undelivered mail for users no longer enrolled in any courses. I checked one http://moodle.org/user/view.php?id=203476&course=1 and found that they were still listed as being subscribed to a forum http://moodle.org/mod/forum/subscribers.php?id=178, despite not having accessed Moodle.org for 321 days.

Show
Helen Foster added a comment - Hi Martin, I've come across this problem on Moodle.org - lots of undelivered mail for users no longer enrolled in any courses. I checked one http://moodle.org/user/view.php?id=203476&course=1 and found that they were still listed as being subscribed to a forum http://moodle.org/mod/forum/subscribers.php?id=178, despite not having accessed Moodle.org for 321 days.
Hide
Jeffery Watkins added a comment -

Yes, they are not enrolled in the class, but are still subscribed to the forums.

Show
Jeffery Watkins added a comment - Yes, they are not enrolled in the class, but are still subscribed to the forums.
Hide
Katarzyna Potocka added a comment -

I've got the same problem with my moodle. After deleting users they still are subscribed in the forums and get the emails, even if they are no longer enrolled in this course.
is there already a solution?

Show
Katarzyna Potocka added a comment - I've got the same problem with my moodle. After deleting users they still are subscribed in the forums and get the emails, even if they are no longer enrolled in this course. is there already a solution?
Hide
Mike Churchward added a comment -

Looks like the problem is associated with the delete user function. When a user is deleted, the user record is flagged as 'deleted' and 'role_assignment' records are deleted, but this does not remove the user data from the course. So, even though you can't see the user in the subscription list of the forum, their subscription record remains in the table.

I think what needs to be done is 'role_unassign' get called for every role the user has instead...

Show
Mike Churchward added a comment - Looks like the problem is associated with the delete user function. When a user is deleted, the user record is flagged as 'deleted' and 'role_assignment' records are deleted, but this does not remove the user data from the course. So, even though you can't see the user in the subscription list of the forum, their subscription record remains in the table. I think what needs to be done is 'role_unassign' get called for every role the user has instead...
Hide
Mike Churchward added a comment -

Committed changes to '/admin/user.php' to use role_unassign when removing a user.

Show
Mike Churchward added a comment - Committed changes to '/admin/user.php' to use role_unassign when removing a user.
Hide
Katarzyna Potocka added a comment -

I think that the role_unassign is called correctly but for some reason the user, even if already deleted entry in role_assignments, has the capability mod/forum:viewdiscussion. The user is not in the list of course participants but is still in the list of forum subscribers. I think it should be done by asking if the user is no student of this course (by checking !has_capability('moodle/legacy:student', $context,$userid)) in function forum_remove_user_subscriptions in mod/forum/lib.php before doing the unsubscription (forum_unsubscribe($userid, $forum->id).
It works fine for me (I hope)

Show
Katarzyna Potocka added a comment - I think that the role_unassign is called correctly but for some reason the user, even if already deleted entry in role_assignments, has the capability mod/forum:viewdiscussion. The user is not in the list of course participants but is still in the list of forum subscribers. I think it should be done by asking if the user is no student of this course (by checking !has_capability('moodle/legacy:student', $context,$userid)) in function forum_remove_user_subscriptions in mod/forum/lib.php before doing the unsubscription (forum_unsubscribe($userid, $forum->id). It works fine for me (I hope)
Hide
Helen Foster added a comment -

Reopening issue as the problem remains on Moodle.org (running 1.9 beta 2).

Show
Helen Foster added a comment - Reopening issue as the problem remains on Moodle.org (running 1.9 beta 2).
Hide
Eloy Lafuente (stronk7) added a comment -

Adding some people here....

Show
Eloy Lafuente (stronk7) added a comment - Adding some people here....
Hide
Petr Škoda (skodak) added a comment -

This could be caused by incorrect permissions in default user role - moodle.org used guest role originally which was causing problems in 1.7. By default the Authenticated role does not have this permission in 1.8, permissions in sites upgraded from 1.7 must be reviewed/reset manually.

Show
Petr Škoda (skodak) added a comment - This could be caused by incorrect permissions in default user role - moodle.org used guest role originally which was causing problems in 1.7. By default the Authenticated role does not have this permission in 1.8, permissions in sites upgraded from 1.7 must be reviewed/reset manually.
Hide
Jeff Wood added a comment -

Same issue here (1.8.2+). Student is not listed as a participant but are forum subscribers.

Trying to remove the student via show/edit current subscribers returns a a message indicating student is not in the course.

Adding the student as a course participant and then unenrolling then does not correct the issue.

Any fixes?

Jeff

Show
Jeff Wood added a comment - Same issue here (1.8.2+). Student is not listed as a participant but are forum subscribers. Trying to remove the student via show/edit current subscribers returns a a message indicating student is not in the course. Adding the student as a course participant and then unenrolling then does not correct the issue. Any fixes? Jeff
Hide
A Knight added a comment -

Issue exists in 1.6 too - unenrolling user doesn't unsubscribe them from forums. Will it be (has it been?) fixed there too?

Show
A Knight added a comment - Issue exists in 1.6 too - unenrolling user doesn't unsubscribe them from forums. Will it be (has it been?) fixed there too?
Hide
Mike Churchward added a comment -

1.8 calls 'role_unassign'. This is in the '1.84 branch, but not the other 1.8 versions.
1.9 calls 'delete_user' which calls 'role_unassign'.
'role_unassign' calls all of the modules' 'role_unassign' functions.

Jeff - 1.8.2 does not have the fix. You need to upgrade to 1.8 latest.

Show
Mike Churchward added a comment - 1.8 calls 'role_unassign'. This is in the '1.84 branch, but not the other 1.8 versions. 1.9 calls 'delete_user' which calls 'role_unassign'. 'role_unassign' calls all of the modules' 'role_unassign' functions. Jeff - 1.8.2 does not have the fix. You need to upgrade to 1.8 latest.
Hide
Jeff Wood added a comment -

Thanks for the info Mike.

Will upgrading to 1.8 latest or 1.9 and re-running the course reset fix the issue?

Show
Jeff Wood added a comment - Thanks for the info Mike. Will upgrading to 1.8 latest or 1.9 and re-running the course reset fix the issue?
Hide
Mike Churchward added a comment -

The latest 1.8 should work... It won't clear out old subscriptions that are still there though. It should work on 1.9, but there seems to reports above that it isn't.

Show
Mike Churchward added a comment - The latest 1.8 should work... It won't clear out old subscriptions that are still there though. It should work on 1.9, but there seems to reports above that it isn't.
Hide
James Williamson added a comment -

Just a reminder that not all student data should be deleted if they no longer are in the course. If they have made a forum posting, and other people have replied to that posting (and even if not), the post should remain even after the student is no longer enrolled.

Show
James Williamson added a comment - Just a reminder that not all student data should be deleted if they no longer are in the course. If they have made a forum posting, and other people have replied to that posting (and even if not), the post should remain even after the student is no longer enrolled.
Hide
Eloy Lafuente (stronk7) added a comment -

If I'm not wrong this should be fixed for 1.8.4 and 1.9 since time ago.

Of course, forum posts of unenroled people aren't deleted at. Only subscriptions from those users to forums + proper checking of enrolment before mail.

Petr, Mike. Can this be closed?

Ciao

Show
Eloy Lafuente (stronk7) added a comment - If I'm not wrong this should be fixed for 1.8.4 and 1.9 since time ago. Of course, forum posts of unenroled people aren't deleted at. Only subscriptions from those users to forums + proper checking of enrolment before mail. Petr, Mike. Can this be closed? Ciao
Hide
Helen Foster added a comment -

Hi,

Sorry to report that this issue is still affecting Moodle.org.

For example, user http://moodle.org/user/view.php?id=82230 with last access 1 year 82 days ago, so not enrolled on any courses, is still listed as a subscriber in 2 Using Moodle forums - http://moodle.org/mod/forum/subscribers.php?id=32 and http://moodle.org/mod/forum/subscribers.php?id=114

I haven't yet tried resetting role defaults - I'll do so soon.

Show
Helen Foster added a comment - Hi, Sorry to report that this issue is still affecting Moodle.org. For example, user http://moodle.org/user/view.php?id=82230 with last access 1 year 82 days ago, so not enrolled on any courses, is still listed as a subscriber in 2 Using Moodle forums - http://moodle.org/mod/forum/subscribers.php?id=32 and http://moodle.org/mod/forum/subscribers.php?id=114 I haven't yet tried resetting role defaults - I'll do so soon.
Hide
Stuart R Mealor added a comment -

I can confirm that Moodle 1.9+ (20080309) has the same problem.
In recycling a course we unenrolled all users from a course.
But their subscriptions still existed, and they got emails from the forums.

Show
Stuart R Mealor added a comment - I can confirm that Moodle 1.9+ (20080309) has the same problem. In recycling a course we unenrolled all users from a course. But their subscriptions still existed, and they got emails from the forums.
Hide
Petr Škoda (skodak) added a comment -

still testing patch, expect commit this week

Show
Petr Škoda (skodak) added a comment - still testing patch, expect commit this week
Hide
Petr Škoda (skodak) added a comment -

1/ there is a cleanup code in forum upgrade code that should delete all stale subscriptions
2/ there is a new test in forum cron that blocks sending to ppl that are not enrolled

thanks for the report

please reopen if necessary

note:commit in parent issue

Show
Petr Škoda (skodak) added a comment - 1/ there is a cleanup code in forum upgrade code that should delete all stale subscriptions 2/ there is a new test in forum cron that blocks sending to ppl that are not enrolled thanks for the report please reopen if necessary note:commit in parent issue
Hide
Jeff Wood added a comment -

Will have to try the fixed version because in the current version 1.9 (20080313) I created a forum and forced everyone to subscribe and it picked up ALL site users and sent mail to them. When I checked the roles for the forum no one was listed. Found out about the error and 600 bounced messages can my way. YIKES

Could there be an issue with my account being a teacher for the front page and for a course?

Jeff

Show
Jeff Wood added a comment - Will have to try the fixed version because in the current version 1.9 (20080313) I created a forum and forced everyone to subscribe and it picked up ALL site users and sent mail to them. When I checked the roles for the forum no one was listed. Found out about the error and 600 bounced messages can my way. YIKES Could there be an issue with my account being a teacher for the front page and for a course? Jeff
Hide
Helen Foster added a comment -

A really big thank you to Petr for fixing this critical bug

Show
Helen Foster added a comment - A really big thank you to Petr for fixing this critical bug
Hide
Andrew Miller added a comment -

Running version Moodle 1.9 + (Build: 20080430) we're still seeing this.

Specifically if I make a new forum and set "Force everyone to be subscribed?" to "Yes, Initially" then everyone with a Moodle account gets the forum notifications.

If I set it to no subscriptions and then modify that setting after making the forum, things work as expected.

Show
Andrew Miller added a comment - Running version Moodle 1.9 + (Build: 20080430) we're still seeing this. Specifically if I make a new forum and set "Force everyone to be subscribed?" to "Yes, Initially" then everyone with a Moodle account gets the forum notifications. If I set it to no subscriptions and then modify that setting after making the forum, things work as expected.
Hide
Andrew Miller added a comment -

Please reopen this as well.

Show
Andrew Miller added a comment - Please reopen this as well.
Hide
Helen Foster added a comment -

Hi Andrew,

I'm happy to reopen this issue if necessary, however based on your comments I'm not sure whether it is. This issue is about forum subscription information being retained when users are no longer enrolled in the course.

Show
Helen Foster added a comment - Hi Andrew, I'm happy to reopen this issue if necessary, however based on your comments I'm not sure whether it is. This issue is about forum subscription information being retained when users are no longer enrolled in the course.
Hide
Andrew Miller added a comment -

Ah.....my apologies.

This is similar in that it involves people not enrolled in the course getting forums emails however different in that it's happening at the point when the forum is created (and they're not enrolled) rather than after they're unenrolled.

Do you think this is a different enough situation I should open a new bug? (We're on 1.8.x right now and with 100+ teachers this would keep us from upgrading to 1.9.x....having one teacher slip and email 4000+ students is a bit....well....unnerving.

Thanks.

Show
Andrew Miller added a comment - Ah.....my apologies. This is similar in that it involves people not enrolled in the course getting forums emails however different in that it's happening at the point when the forum is created (and they're not enrolled) rather than after they're unenrolled. Do you think this is a different enough situation I should open a new bug? (We're on 1.8.x right now and with 100+ teachers this would keep us from upgrading to 1.9.x....having one teacher slip and email 4000+ students is a bit....well....unnerving. Thanks.
Hide
Helen Foster added a comment -

Yes please do open a new bug Andrew.

Show
Helen Foster added a comment - Yes please do open a new bug Andrew.
Hide
Mary Parke added a comment -

Yes, please open a new ticket as the following is still happening for us:

We are on version 1.9.5 (Build: 20090518) and still have this problem. A student is unenrolled from the course and still receives all forum subscriptions for the course - and in particular, the news forum (with forced subscription).

Is this a conflict with the default forced subscription in a news forum?

Show
Mary Parke added a comment - Yes, please open a new ticket as the following is still happening for us: We are on version 1.9.5 (Build: 20090518) and still have this problem. A student is unenrolled from the course and still receives all forum subscriptions for the course - and in particular, the news forum (with forced subscription). Is this a conflict with the default forced subscription in a news forum?
Hide
Helen Foster added a comment -

Mary, thanks for your comment.

Just wondering whether you have recently upgraded your site, and if so, from which version? Also, have you tried resetting your roles to default?

Show
Helen Foster added a comment - Mary, thanks for your comment. Just wondering whether you have recently upgraded your site, and if so, from which version? Also, have you tried resetting your roles to default?
Hide
Mary Parke added a comment -

Helen, thanks for responding.

Our roles for student are the defaults on the site and we are on the same version listed in my last response.

Show
Mary Parke added a comment - Helen, thanks for responding. Our roles for student are the defaults on the site and we are on the same version listed in my last response.

Dates

  • Created:
    Updated:
    Resolved: