DESCRIPTION OF THE PROBLEM:
- When og2list module is enabled, og stops sending notifications for all groups.
- BUT, og2list is only sending notifications for groups with an og2list mailing list (a row in og2list_groups and a recipient set in the group's edit form).
Fixing the problem requires patches to both og2list and og. This issue holds the og2list patch.
For the corresponding og patch, see: http://drupal.org/node/162307.
HOW TO REPLICATE THE PROBLEM:
- You need the latest og: version 5.x-3.x-dev (HEAD) and the latest 5.x og2list version (og2list-HEAD.tar.gz)
- Leave the og2list module DISABLED. Go and create a group, set the group's comment settings to read/write, subscribe a couple users to it for email notifications (in the My Subscription). Obviously you need to be able to receive these notifications to test. Make sure you do not set a mailing list recipient for the group! (you shouldn't be able to if og2list is disabled).
- Test that notifications are working as they should in og. Make a forum post, blog comment, whatever in the group. Run the site's cron.php if it doesn't run automatically. You should see email notifications coming in from og. They are easy to spot, as by default they will have an email footer that looks like this:
View original: http://beta.postcarbon.org/testing_notifications#comment-3535
Post reply: http://beta.postcarbon.org/comment/reply/4631/3535
--
You are subscribed to the group 'ogtest' at 'BETA - Post Carbon Institute - BETA'.
To manage your subscription, visit http://beta.postcarbon.org/og/manage/4629
- Now you have simulated an existing site with existing groups, users and notifications. Go to your site's admin/build/modules page and turn ON og2list.
- Create a new blog/forum/comment in your group. Run cron.php again. Note that you should NOT receive any notifications! They will have stopped. This is because og tests to see if og2list is enabled, and if so skips its notifications.
THE FIX:
As suggested by Moshe here: http://drupal.org/node/162307#comment-279952
the patch to og (og_hook_og_notify.patch) from that node now calls a hook_og_notify() using module_invoke(), instead of just testing to see if og2list is enabled.
This way any module that wants to can implement hook_og_notify() and return TRUE if it wants to handle the notifciations. If og receives a TRUE back from any module implementing this hook, it lets the other module handle the notification.
On the og2list side, og2list needs to implement this hook but only return TRUE for notifications it intends to handle. In the og2list code this is determined in two spots (for a node insert or a comment insert in hook_nodeapi()), and the notification only happens iff the group has a mailing list (recipient set in the edit form and a mailing list tab visible for the group manager or admins).
Here is the code og2list is using to determine if it handles a notification, from one of those 2 spots:
$edit = (array) $node;
if(count($edit['og_groups'])) {
$edit['og_nids'] = $edit['og_groups'];
// Find the lists to send to.
og2list_get_groups($edit);
}
if (count($edit['ogs'])) {
og2list_send_mail($edit);
}
The attached patch implements the same logic in hook_og_notify() to properly return TRUE or FALSE. In this manner og will continue to notify for groups that don't have mailing list (i.e. your existing groups and users, who would otherwise start to wonder what happened when all their notifications vanished). When a group does have a mailing list, og2list takes over notification and users can just reply to comment, and also send mail to the group recipient to create new forum nodes.
TESTING THE PATCH:
This one is a complicated one to test for sure. I recommend the following:
1) replicate the problem as described above
2) apply the og side of the patch to og from http://drupal.org/node/162307 (og_hook_og_notify.patch)
3) apply the attached patch to your og2list (og2list_hook_og_notify.patch)
4) Now leave og2list enabled, go to your group that doesn't have a mailing list from the testing, and make a comment. You should receive the og notification as you would expect
5) Edit your test group, set a mailing list recipient for it. This will make the Mailing List tab appear and should also make og2list take over notifications.
6) Make another comment, run cron.php twice, and see if you get any og2list mails. They are also easy to spot vs. the og notifications as they do NOT have footer text (yet) and they come from the group recipient address, not the site-wide email address configured in site information.
Obviously this is not the most trivial one to test, although a serious issue. I am available to provide support to anyone who is willing to help me test this! I also need help testing that manage subscription patch (http://drupal.org/node/161393#comment-27905)! Both need to be committed before we make a release version of og2list... until then it is definitely Broken for existing sites/groups. But afterwards our long awaited stable 5.x release should be ready... exciting stuff!
Thanks in advance to all/anyone who can help with the testing!
| Comment | File | Size | Author |
|---|---|---|---|
| #4 | og2list_hook_og_notify_0.patch | 1.33 KB | damien_vancouver |
| og2list_hook_og_notify.patch | 1.15 KB | damien_vancouver |
Comments
Comment #1
damien_vancouver commentedMoshe has committed the og side of this patch.
So that means if you are testing it, and you are using the latest HEAD version of og, you don't need to apply the og_og_notify.patch.
If you are using og 3.1 or a release version, you do still need to apply that patch.
Comment #2
miglius commentedI cannot replicated the problem with the HEAD og module.
My Drupal 5.2 installation has og HEAD module v 1.368 and og2list at revision v 1.109. The og2list is disabled. I have created two users and subscribed them to a Test group. Have set group subscription to individual mails. When a user posted a new blog entry the notification was mailed out to both users.
Now I have enabled a og2list module, didn't set a group mail address and created a new blog entry. The notification was sent out as well.
Comment #3
damien_vancouver commentedI realized looking over this again that you wouldn't see the behaviour with the (then) HEAD og, because moshe committed the og side of the patch so quickly.
With og's half of the fix comitted, og would call hook_og_notify() and unless some other module returned TRUE (which og2list before this patch wouldn't), then it would assume no one else wanted to handle the notification and send it anyway.
It should be possible to replicate the problem with og 3.1, but seeing as moshe comitted that side anyway, what is more important is to test that notifications work properly, and og2list sends the only notifications for things it wants to accept notifications for.
There is another patch I will have ready that veggieryan has created for our private version, which allows you to specify og2list's omitted content types it won't notify for (just like og has omitted content types). It should also be tested and committed at the same time as this fix and the broken subscription form fix in http://drupal.org/node/161393.
We'll have that posted shortly for og2list HEAD.
Comment #4
damien_vancouver commentedveggieryan found a bug in the initial version of this patch, where the og_get_groups() function would cause errors when you add a new group.
non-harmful Errors similar to the following would occur when adding a new group:
# warning: array_merge() [function.array-merge]: Argument #2 is not an array in /home/beta_standard_drupal5/public_html/sites/all/modules/og2list/og2list.module on line 1694.
# warning: implode() [function.implode]: Bad arguments. in /home/beta_standard_drupal5/public_html/sites/all/modules/og2list/og2list.module on line 1694.
The attached version of the patch properly checks that the node is not a group and that the node is in at least one organic group before trying to run og_get_groups():
The change is the addition of the if statement.