Hi,
when I activate activism module, Drupal return this messages :
warning: in_array() [function.in-array]: Wrong datatype for second argument in /var/www/drupal/sites/all/modules/activism/activism.module on line 612.
| Comment | File | Size | Author |
|---|---|---|---|
| #8 | 469924.patch | 757 bytes | bradweikel |
Comments
Comment #1
brianbrown commentedI have this issue also!
-Brian
Comment #2
brianbrown commentedMany, many modules installed.
Comment #3
Anonymous (not verified) commentedI think this could be a callback issue, like a conflict between a callback in the module and some other path setting. What other modules do you have installed?
M
Comment #4
javajones commentedI go the following warning, but it went away after I enabled the petition module:
* warning: in_array() [function.in-array]: Wrong datatype for second argument in /home/bobo/public_html/ahora/modules/activism/activism.module on line 612.
* warning: in_array() [function.in-array]: Wrong datatype for second argument in /home/bobo/public_html/ahora/modules/activism/activism.module on line 612.
Comment #5
brianbrown commentedNot for me!
Comment #6
bradweikel commentedJust to confirm --
On a fresh install, I enabled only the Activism module, and got one warning.
Then I enabled the Petition module and it went away.
Glancing at the code, it looks like you just need to initialize $activism_cta_forms in activism_form_alter, ie "$activism_cta_forms = array();"
Don't have time to test and patch right now, though. Sorry.
Comment #7
obeygiant commentedJust to clarify for the noob, are you referring to line 612?
if (in_array($form['form_id']['#value'], $activism_cta_forms)) {
or are you referring to line 607
$activism_cta_forms[] = $cta_type['module'] . '_activism_cta_form';
Comment #8
bradweikel commentedPatch attached.
Mini PHP lesson for obeygiant:
On line 612, $activism_cta_forms is passed to the in_array function, and in_array assumes that it is in fact an array.
However, the only place that $activism_cta_forms is set is on line 607, which is inside a foreach loop (606-608). So if the loop is executed zero times, $activism_cta_forms is not defined, and line 612 throws a warning.
My patch just makes sure that $activism_cta_forms is always initialized by adding the following line BEFORE the foreach loop:
$activism_cta_forms = array();
It turns out this is sort of a non-bug, because PHP handles the situation the way we want, but it's a good best practice to get rid of warnings like this.
Comment #9
obeygiant commentedThank you for the tutorial,the patch and for handling the question with "kid gloves" as I'm obviously still learning. This is why I defer to those that are more knowledgeable than myself.
Comment #10
coryms commentedWorked for me! Thanks. Added $activism_cta_forms = array(); and errors went away.