Moodle

Get_course_users in Forum/lib.php causes lots of incorrect e-mail subscriptions.

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Fixed
  • Affects Version/s: 1.9
  • Fix Version/s: 1.9
  • Component/s: Forum, Libraries
  • Labels:
    None
  • Affected Branches:
    MOODLE_19_STABLE
  • Fixed Branches:
    MOODLE_19_STABLE

Description

Line 1921 of forum/lib.php the call:
$results = get_course_users($course->id); // Otherwise get everyone in the course

returns an invalid list of users, which it uses to send out new forum postings, and unrelated users end up getting forum postings.

IMO Get_course_users is completely broken... it seems to return way too many results!

Issue Links

Activity

Hide
Dan Marsden added a comment -

should be replaced with something that calls get_users_by _capability - my guess is maybe using 'mod/forum:initialsubscriptions'

Dan

Show
Dan Marsden added a comment - should be replaced with something that calls get_users_by _capability - my guess is maybe using 'mod/forum:initialsubscriptions' Dan
Hide
Dan Marsden added a comment -

something like this seems to work:
replace:
$results = get_course_users($course->id); // Otherwise get everyone in the course

with:

$context = get_context_instance(CONTEXT_COURSE, $course->id);
$fields='u.id, u.username, u.firstname, u.lastname, u.maildisplay, u.mailformat, u.maildigest, u.emailstop, u.imagealt,
u.email, u.city, u.country, u.lastaccess, u.lastlogin, u.picture, u.timezone, u.theme, u.lang, u.trackforums, u.mnethostid';
$results= get_users_by_capability($context, 'mod/forum:initialsubscriptions', $fields, '', '','','','', false, true);

Show
Dan Marsden added a comment - something like this seems to work: replace: $results = get_course_users($course->id); // Otherwise get everyone in the course with: $context = get_context_instance(CONTEXT_COURSE, $course->id); $fields='u.id, u.username, u.firstname, u.lastname, u.maildisplay, u.mailformat, u.maildigest, u.emailstop, u.imagealt, u.email, u.city, u.country, u.lastaccess, u.lastlogin, u.picture, u.timezone, u.theme, u.lang, u.trackforums, u.mnethostid'; $results= get_users_by_capability($context, 'mod/forum:initialsubscriptions', $fields, '', '','','','', false, true);
Hide
Dan Marsden added a comment -

now fixed in 1.9 and HEAD

Show
Dan Marsden added a comment - now fixed in 1.9 and HEAD
Hide
Tim Hunt added a comment -

Why get_context_instance(CONTEXT_COURSE, $course->id); and not the forum context?

Show
Tim Hunt added a comment - Why get_context_instance(CONTEXT_COURSE, $course->id); and not the forum context?
Hide
Tim Hunt added a comment -

On jabber, dan said that as far as he can remember, there was no good reason for CONTEXT_COURSE - that is, it was a mistake. I'm fixing it as part of MDL-14876.

Show
Tim Hunt added a comment - On jabber, dan said that as far as he can remember, there was no good reason for CONTEXT_COURSE - that is, it was a mistake. I'm fixing it as part of MDL-14876.
Hide
Tim Hunt added a comment -

Although, as the previous comments say, there was a problem with this fix, they are being fixed as part of another bug, and the fix here did solve the immediate problem with spurious mail-outs, so closing.

Show
Tim Hunt added a comment - Although, as the previous comments say, there was a problem with this fix, they are being fixed as part of another bug, and the fix here did solve the immediate problem with spurious mail-outs, so closing.

People

Vote (0)
Watch (3)

Dates

  • Created:
    Updated:
    Resolved: