Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
I get this error when trying to view or edit certain nodes.
Recoverable fatal error: Argument 1 passed to _menu_attributes_form_alter() must be an array, null given, called in .../sites/all/modules/menu_attributes/menu_attributes.module on line 133 and defined in _menu_attributes_form_alter() (line 146 of.../sites/all/modules/menu_attributes/menu_attributes.module).
Comment | File | Size | Author |
---|---|---|---|
#12 | 1151594.patch | 609 bytes | amateescu |
Comments
Comment #1
chrisgross CreditAttribution: chrisgross commentedI did not see this error before upgrading to rc1.
Comment #2
chrisgross CreditAttribution: chrisgross commented*upgrading priority to major since I am unable to edit some nodes.
Comment #3
jlaurin CreditAttribution: jlaurin commentedsubscribe
Comment #4
Dave ReidI am not able to duplicate this error with a core install + menu_attributes.
Comment #5
chrisgross CreditAttribution: chrisgross commentedFrom what I can tell, this issue seems to have spontaneously resolved itself. If I see it again, I will let you know. Thanks.
Comment #6
chrisgross CreditAttribution: chrisgross commentedThis error came back again, but the message goes away if I change line 131 of menu_attributes.module from
if (isset($form['menu'])) {
to
if (isset($form['menu']['link'])) {
I'm not sure if it's right but without it, I can't edit some nodes. It seems to be a safe thing to do because the few lines afterwards only use $form['menu'] when using $form['menu']['link'], so I don't think it will break anything.
Comment #7
jlaurin CreditAttribution: jlaurin commentedYour hint works :).
Thank you
Comment #8
dlumberg CreditAttribution: dlumberg commentedI changed line 146 from:
to:
I did it this way because an ajax submit might not pass everything from the form and the function definition is basically stating that it needs an array or it will break.
There may be some reason for that, I don't know.
Comment #9
Dave ReidAgain, according to menu_form_node_form_alter() which will always run *before* menu_attributes. How could $form['menu']['link'] *not* be an array if isset($form['menu']) is TRUE?
Comment #10
stuzza CreditAttribution: stuzza commentedI've got a situation where $form['menu'] hasn't been set, the revisioning module blithely adds $form['menu']['#collapsed'] = true; without checking if $form['menu'] exists first, so that by the time _menu_attributes_node_form_alter() gets to it, $form['menu'] does exist, but $form['menu']['link'] does not.
I guess it's hard to write a module in anticipation that another contrib module might randomly bring the crazy, but I think that if you're doing things to $form['menu']['link'] it would be a good sense to check if it's there beforehand, and not just its parent.
Cheers
Stuart
Comment #11
dibs CreditAttribution: dibs commentedsubscribe
Comment #12
amateescu CreditAttribution: amateescu commentedThis seems like a good argument to me, so I commited the attached patch that checks for $form['menu']['link'].
http://drupalcode.org/project/menu_attributes.git/commit/51f1830
Comment #14
Sergii CreditAttribution: Sergii commentedThe same affects me and I agree with the patch supplied.
Please include the change in the next release.
Comment #15
amateescu CreditAttribution: amateescu commentedThe patch has already been committed and it's now currently in 7.x-1.x-dev.
Comment #16
lennyaspen CreditAttribution: lennyaspen commented#8 Worked for me, thanks