I believe I am still running into problems with the email on/off checkbox settings in commons3.3, despite the various fixed bug reports on the same topic.
Specifically, I believe the issue raised by the OP by @jide in
π
Message Subscribe sends emails regardless of context
Closed: outdated
and elaborated on in https://drupal.org/comment/6681468#comment-6681468 has not been addressed.
Emails are sent out when a user has any email_* related flag set, regardless of whether the flag matches the particular context/node in question.
The fixes and tests done to this point in the previous issues look like they are fixed because the tested only having one email_* flag set at at time, in which case a user is able to successfully toggle the flag on/off as expected.
But once more than one email_* flag is in play, and one of them is set to ON, none of the flags set to OFF are respected. So if a user has one email_* flag set to ON, they will get emails for everything they follow, regardless of the individual email_* flag settings.
To reproduce:
- user1 and user2 have "Send email notifications by default." checked
- user1 create GroupA.
- user2 follow GroupA.
- user2 create a post PostB on GroupA
- user2 goes to their notification-settings page and sets GroupA to "do not send email"
So at this point:
- user1 will now follow and receive emails for all groupA content
- user2 should only receive emails for comments on PostB
Now:
- user1 create PostC on GroupA
Result:
- both user1 and user2 will receive emails.
In the code
<?php
function message_subscribe_get_subscribers(){
//...
//at this point Array ( [8] => Array ( [notifiers] => Array ( ) [flags] => Array ( [0] => commons_follow_node ) )
//notifiers is an empty array as expected
_message_subscribe_add_default_notifiers($uids);
//at this point Array ( [8] => Array ( [notifiers] => Array ( ) [flags] => Array ( [0] => commons_follow_node ) )
//notifiers is an empty array as expected, so the problem is not the default_notifiers
drupal_alter('message_subscribe_get_subscribers', $uids, $values);
//now we have Array ( [8] => Array ( [notifiers] => Array ( [email] => email ) [flags] => Array ( [0] => commons_follow_node ) )
//so the Email notifier has been added by drupal_alter
//...
}
?>
So then looking at drupal_alter, as pointed out by @jide in the original issue
<?php
function message_subscribe_email_message_subscribe_get_subscribers_alter(&$uids, $values) {
//...
// at no point does this function check to make sure it is matching against the relevant flag for this particular node/context
//any match for user with an email_* flag will cause emails to be sent
$result = $query->fields('f', array('uid'))
->condition('fid', $flag_ids, 'IN')
->condition('uid', array_keys($uids), 'IN')
->groupBy('uid')
->execute()
->fetchAll();
foreach ($result as $row) {
// Add 'email' to the list of notifiers.
$uids[$row->uid]['notifiers']['email'] = 'email';
}
//...
}
?>
At no point does this function check to make sure it is matching against the relevant flag for this particular node/context. Any match for user with an email_* flag will cause emails to be sent. So if a user has emails turned on for one context, emails will get sent in all contexts.
I have been pulling my hair out trying to figure out why sometimes it seems like i can turn emails on and off, and then the next moment they are always on. initially my test users have just one content they followed and all is well. as my test users do more and subscribe to more content, they start having more than one email_* flag, and then all heck breaks loose.
Closed: outdated
1.0
Code
Not all content is available!
It's likely this issue predates Contrib.social: some issue and comment data are missing.