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).

CommentFileSizeAuthor
#12 1151594.patch609 bytesamateescu
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

chrisgross’s picture

I did not see this error before upgrading to rc1.

chrisgross’s picture

Priority: Normal » Major

*upgrading priority to major since I am unable to edit some nodes.

jlaurin’s picture

subscribe

Dave Reid’s picture

Status: Active » Postponed (maintainer needs more info)

I am not able to duplicate this error with a core install + menu_attributes.

chrisgross’s picture

From what I can tell, this issue seems to have spontaneously resolved itself. If I see it again, I will let you know. Thanks.

chrisgross’s picture

This 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.

jlaurin’s picture

Your hint works :).

Thank you

dlumberg’s picture

I changed line 146 from:

function _menu_attributes_form_alter(array &$form, array $item = array(), array &$complete_form) {

to:

function _menu_attributes_form_alter( &$form = array(),  $item = array(),  &$complete_form = array()) {

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.

Dave Reid’s picture

Again, 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?

stuzza’s picture

I'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

dibs’s picture

subscribe

amateescu’s picture

Status: Postponed (maintainer needs more info) » Fixed
FileSize
609 bytes

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.

This 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

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

Sergii’s picture

The same affects me and I agree with the patch supplied.
Please include the change in the next release.

amateescu’s picture

The patch has already been committed and it's now currently in 7.x-1.x-dev.

lennyaspen’s picture

#8 Worked for me, thanks