Drupal 7.27 introduced some changes in ajax.inc's ajax_form_callback() function regarding the #commands field in the $result array. The changes don't check if the field exists when merging it into the new value. This can lead to "undefined index" messages under certain circumstances.

I use webform_feedback together with webform_ajax to implement a global feedback form on a site. After upgrading to Drupal 7.27, I get the following notices and warnings after hitting the submit button:

Notice: Undefined index: #commands in ajax_form_callback() (line 404 of drupal/includes/ajax.inc).
Warning: array_merge(): Argument #2 is not an array in ajax_form_callback() (line 404 of drupal/includes/ajax.inc).
Warning: array_merge(): Argument #2 is not an array in ajax_render() (line 288 of drupal/includes/ajax.inc).
Warning: array_unshift() expects parameter 1 to be array, null given in ajax_render() (line 295 of drupal/includes/ajax.inc).

The form does not show the content it should (reloaded form, success message) after submitting, it stays as is.

With the provided patch, existence of #commands is checked and the form works again as it used to.

Comments

Christopher Herberte’s picture

Patch indeed fixed errors that were introduced with 7.27 and webform_ajax thanks :O

jannis’s picture

Patch fixed same errors from using 7.31 and webform ajax 7.x-1.1+2-dev

dcam’s picture

Status: Active » Needs review

Setting the status so Testbot will pick it up.

Status: Needs review » Needs work

The last submitted patch, fix_undefined_index_commands.patch, failed testing.

pushpinderchauhan’s picture

Status: Needs work » Needs review
StatusFileSize
new418 bytes

Rerolled above patch as it unable to apply.

jannis’s picture

er.pushpinderrana your patch applied perfectly. thanks

adamzimmermann’s picture

The patch in #5 worked perfectly for me also. Thanks.

adamzimmermann’s picture

The patch in #5 worked perfectly for me also. Thanks.

jannis’s picture

just ran this patch on 7.34 fixed the same problem that's been in each release since 7.27. This patch needs to be committed

Status: Needs review » Needs work

The last submitted patch, 5: fix-undefined-index-commands-2288291-5.patch, failed testing.

Status: Needs work » Needs review
vadim.hirbu’s picture

StatusFileSize
new424 bytes

Just updated latest patch.

Status: Needs review » Closed (outdated)

Automatically closed because Drupal 7 security and bugfix support has ended as of 5 January 2025. If the issue verifiably applies to later versions, please reopen with details and update the version.