Closed (fixed)
Project:
Notifications
Version:
5.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
24 Mar 2008 at 04:24 UTC
Updated:
7 Apr 2008 at 22:42 UTC
I am writing a module that makes use of the notifications api. It provides a subscription that never has 'fields'.
However, when I go to save them I get:
warning: Invalid argument supplied for foreach() in notifications.module on line 379
Attached is a patch that makes the 'foreach fields as name => value' section conditional on there being fields
(sorry - patch cleans up line endings again) Important part is (line 189 of the patch):
- foreach ($subscription->fields as $name => $value) {
- db_query("INSERT INTO {notifications_fields} (sid, field, value) VALUES(%d, '%s', '%s')", $subscription->sid, $name, $value);
+ if (is_array($subscription->fields)) {
+ foreach ($subscription->fields as $name => $value) {
+ db_query("INSERT INTO {notifications_fields} (sid, field, value) VALUES(%d, '%s', '%s')", $subscription->sid, $name, $value);
+ }
| Comment | File | Size | Author |
|---|---|---|---|
| notifications.module.patch | 12.35 KB | andremolnar |
Comments
Comment #1
jose reyero commentedWe are not really contemplating such case and more of the api may fail for subscriptions with no fields.
(Unless we actually get a plug-in which really uses that)
Anyway that won't impact anything else and we try this to be as reusable as possible for everybody, so the patch is in.
Comment #2
andremolnar commentedThanks.
Here is the use case:
The plug-in I'm working on is specific to a site, so not very useful to anyone else (otherwise I'd be glad to share it). But, basically, the subscription events are triggered by queries that run on cron.
The subscription type has no specific fields.
subscription_save is called as each new user signs up without fields.
Comment #3
Anonymous (not verified) commentedAutomatically closed -- issue fixed for two weeks with no activity.