As a result of some improvements in the Notifications package, the query arguments returned by hook_notifications() need some small change. One line patch attached.
| Comment | File | Size | Author |
|---|---|---|---|
| #17 | og_notifications_query_args_04.patch | 1.04 KB | jose reyero |
| #9 | og_notifications_query_args_03.patch | 1.01 KB | jose reyero |
| #7 | og_notifications_query_args_02.patch | 1.03 KB | jose reyero |
| og_notifications_query_args.patch | 771 bytes | jose reyero |
Comments
Comment #1
ryan_courtnage commentedHi Jose,
I believe that there is something wrong with this patch (or perhaps the new query builder). I'm running your latest notifications and messaging (DRUPAL-6--1 as of January 12), and have applied the patch attached to this bug. There are 3 observations:
1) The error "[function.array-merge]: Argument #1 is not an array in " that I've seen others complain of is fixed
2) OG notifications does *not* add anything to notifications_queue (even though there are subscriptions).
3) All other events also fail to add their notifications to notifications_queue. For example, if a user is subscribed to a comment thread in a forum, no notifications will be added to the queue so long as og_notifications is enabled.
Here is a resulting query generated for a comment on a forum post. You will see that the og_notification additions to the query result in no results ever being returned (I'm guessing because of "AND (oga.nid = %d)":
INSERT INTO {notifications_queue}(uid, sid, module, eid, send_interval, send_method, cron, created, conditions) SELECT DISTINCT s.uid, s.sid, s.module, %d, s.send_interval, s.send_method, s.cron, %d, s.conditions FROM {notifications} s INNER JOIN {notifications_fields} f ON s.sid = f.sid LEFT JOIN {og_ancestry} oga ON f.field = 'group' AND f.value = CAST(oga.group_nid AS CHAR(255)) WHERE (s.status = 1) AND (s.event_type = '%s') AND (s.send_interval >= 0) AND (s.uid <> %d) AND (oga.nid = %d) AND ((f.field = '%s' AND f.value = '%s') OR (f.field = '%s' AND f.value = '%s') OR (f.field = '%s' AND f.value = '%s')) GROUP BY s.uid, s.sid, s.module, s.send_interval, s.send_method, s.cron, s.conditions HAVING s.conditions = count(f.sid)
Thanks!
Comment #2
ryan_courtnage commentedHere's an attempt to better illustrate the problem.
Test: Commenting on a forum post that user is subscribed to (forum not related to og).
og_notifications.module enabled.
$args is
The above query results in 0 rows being affected (nothing is added to the notifications queue).
Here is the same forum post test, but with the og_notifications module disabled:
$args is
This properly results in a notification being added to the queue.
Comment #3
igorik commentedI can confirm this comment at all.
with enabled og notification (with 1 line patch)
watchdog error message stopped, but all notifications are broken, nothing is send
Igorik
Comment #4
amitaibusetting the correct status.
Comment #5
karens commentedJust looking at the code (not testing anything) I see a couple possible problems:
1) It looks like Notifications expects 'join' and 'where' to be arrays, but og_notifications is passing strings (around line 261 of og_notifications.module)
2) It looks like Notifications then merges the passed information into arrays, where the string values from OG might create some odd results (around line 418 of notifications.module)
3) Then the (possibly borked) 'join' array is used to add arguments to the query (around line 487 of notifications.module). I think that is actually a Notifications bug, since it seems to think there might be 'join args' but they are never defined anywhere.
I can't test the theory, but someone could see what happens if in addition to the above patch you also fix og_notifications so it is sending an array instead of a string for the 'join'. If that doesn't work, try removing 'join' from the foreach list used to create the args.
Anyway I think something somewhere in there is a problem.
Comment #6
karens commentedEdit, the $join array is not used for adding join args, but I still think it's a mistake to have 'join' in there when there are no 'join args' defined anywhere.
Comment #7
jose reyero commentedI think there's problem with that query. Though the og table is a LEFT JOIN, there's this WHERE condition that will make it work as an INNER JOIN: oga.nid = %d
We need to either add that condition on the join, which is what this patch does or other option, if someone wants to try may be WHERE (oga.nid = %d OR oga.nid IS NULL)
Comment #8
ryan_courtnage commentedUsing og_notifications_query_args_02.patch, the following error results after leaving a comment on a subscribed thread:
warning: array_merge() [function.array-merge]: Argument #1 is not an array in /home/rcourtna/workspace/tysc/sites/all/modules/notifications/notifications.module on line 440
I'm not entirely sure how to make the alternate change you recommended. Would it look like this?:
Comment #9
jose reyero commented@rcourtna,
Thanks for testing the patch. The issue was not in the patch but in notifications module, that array was not properly initialized, it should work now.
Update to latest notifications-dev (just committed, may take a while to get repackaged so better use cvs) and run update.php
This new patch is the same with some addition. It uses a new feature in notifications that should be a performance boost for og queries, see #364734: Performance boost: Store field values as integer
Comment #10
mariagwyn commentedApplied the patch, got the following errors:
Comment #11
jose reyero commented@mariagwyn,
You need to update to the latest (dev) version of Notifications and run update.php
Comment #12
igorik commentedHi
I can confirm that with latest dev versions of notifications and messaging - these modules now works both with og_notifications enabled.
But - og_notification doesn't work. I tried og_notification without any patch and with your latest patch from #9 too.
It doesn't works with both cases.
Doesn't works mean no notification about new content in the group was sent (I try user and admin)
Thanks
Igorik
Comment #13
ryan_courtnage commentedI can confirm what igorik is seeing. Running the latest notifications-dev, with og_notifications_query_args_03.patch applied. Notifications and messaging work, but no OG notifications for new group content.
Comment #14
mariagwyn commented@jose:
I was pretty sure I had already updated, but since I wasn't sure, I uninstalled all modules (removing DB tables), reinstalled the two dev modules, ran update (nothing to update...), and immediately upon visiting my home page, received errors. And when I try to post to a group which is supposed to send, also receive errors. Here is a shortened list:
Not sure if this is the issue, but I am not seeing a column f.intval anywhere in my DB.
Maria
Comment #15
mariagwyn commentedI backported to the non-dev versions, reversed the OG patch. I have everything working now, except OG Notifications. More specifically, a notification is sent out as a "Node Creation" rather than an OG Notification. I checked this via the message templates: waht is pulled when I create any kind of Group post is a message using the Node Creation templates. So, it works, but not quite like I assume it should. Again, this is not on the dev versions (which I couldn't get to work at all and gave up trying for lack of time...but I can try again if it helps).
Comment #16
igorik commentedMaria, I am not sure of sense of trying and reporting about non dev versions of messaging and notifications with this bug, becasue they are more then 2 months old.
Could you try please the new dev versions with clean drupal 6 installation?
Comment #17
jose reyero commentedWell, some of the previous errors were because the good code was in the CVS, not the same as the -dev package until after a few hours (it may take a day to be repackaged).
Some others were because my previous patch was crap.
I think this is the good one. This og query was needing some very special parameters which I've just built into notifications query builder.
If this works and someone with a big enough install (many groups, many users subscribed) could also report on performance improvements (time of previous query in og/notficiations stable vs time of this new version) that would be great.
I insist this patch works with Notifications CVS (6.x branch). It will be in the .tar.gz package in a few hours, or to be sure, tomorrow
Thanks for the reviews and testing.
Comment #18
igorik commentedHi
With the latest dev version of Notifications no notifications are sent at all. It doesn't matter if og_notification is enabled or disabled.
There are no notifications sent. I had to use version before this again.
Comment #19
ryan_courtnage commentedHi Jose,
With og_notifications_query_args_04.patch and the latest notifications (DRUPAL-6--1 tag), notifications are properly added to the queue (both OG content notifications and other notifications).
However, when trying to process the queue (using Run Process button), the following error is created for each item in the queue:
Ryan
Comment #20
jose reyero commented@rcourtna,
I haven't seen this one in my tests. Is it possible that you have old rows in that table (without events)? Could you reset the queue and try again?
Comment #21
ryan_courtnage commentedHi Jose,
Well perhaps. Today I was able to duplicated the problem a couple of times, but then it magically disappeared! We may never know the cause, but it all seems to be working just fine now. Thanks a bunch.
Ryan
Comment #22
igorik commentedHi
With latest dev notifications and messaging, it works for me too.
notifications are sent, include og notifications.
thanks for your work
Igorik
Comment #23
mariagwyn commentedI updated everything, and it seems to be working. Notifications are still being sent from the General events message template rather than the OG template, but they are being successfully sent, no errors!
thanks,
m
Comment #24
Zen commentedCommitted to OG HEAD. Tested with MySQL only on my end.
Patch needs to be back-ported based on the outcome of #364734 .
-K
Comment #25
AFowlesubscribe
Comment #26
jose reyero commentedIt doesn't need backporting, nor you can unless we backport also the Notifications D6 feature (reworked query builder), no plans for that for now. I'll open a new issue here if so.