Early Bird Registration for DrupalCon Portland 2024 is open! Register by 23:59 PST on 31 March 2024, to get $100 off your ticket.
Spotted this on a node this morning:
warning: key() [function.key]: Passed variable is not an array or object in [snip]/sites/all/modules/comment_notify/comment_notify.module on line 129.
The issue is the #default_value line in the else statement below:
if (count($available_options) > 1) {
$form['notify_type'] = array(
'#type' => 'radios',
'#options' => $available_options,
'#default_value' => $preference,
);
}
else {
$form['notify_type'] = array(
'#type' => 'hidden',
'#default_value' => key($available_options),
);
}
Comment | File | Size | Author |
---|---|---|---|
#7 | comment_notify-array-warning-476526-7.patch | 1.03 KB | webchick |
#6 | comment_notify-array-warning-476526-6.patch | 795 bytes | webchick |
Comments
Comment #1
gregglesInteresting. If you go to admin/settings/comment_notify and submit the page, does this error go away? Also, what are your settings on that page?
Comment #2
gregglesComment #3
domesticat CreditAttribution: domesticat commentedInteresting - you're right, when I saved the page, the error went away. I wonder if it will come back...?
Options:
- all 10 content types are enabled for notification
- both 'All comments' and 'Replies to my comment' are selected as subscription modes
- default state for both anonymous and registered users is 'all comments'
- both emails have body text.
Comment #4
gregglesI think what happened is that you installed the module, but didn't configure it. When that happens it should figure out sane defaults, but that is sometimes tricky for things like this that are based on content type.
Now that I know the steps to repeat (install, don't configure) it should be possible to track this down to some variable_get that doesn't have the right defaults.
Comment #5
webchickI got this too. I know I'm supposed to read instructions, but I don't, so it'd be nice if I did not get an error when I haven't configured the module yet.
Comment #6
webchickWell, here's one option, which just doesn't proceed if no available options are found.
This might lead to support requests saying the module doesn't do anything, but I guess that's better than support requests about error messages. :) Plus, if nothing happens, the most logical next place to look would be the settings page.
Comment #7
webchickHm. Actually, I think the real problem is the format of the array is incorrect (or else the code to loop through is incorrect).
Seems like maybe you want this instead.
Comment #8
Dave ReidMaybe the comment_notify_available_alerts variable needs to be run through array filter by using:
Then all we'd need to do is:
Comment #9
gregglesWebchick's fix sticks closest to the original intent. Committed! http://drupal.org/cvs?commit=221674
@dave I don't follow how to integrate your idea, but I imagine it's simpler. Patch or it never happened ;)