Ajax Form Callback causes PHP TypeError: array_unshift(): Argument #1 ($array) must be of type array, null given

Created on 17 September 2022, over 2 years ago
Updated 9 February 2023, almost 2 years ago

Problem/Motivation

The Event Logger module assumes that a form will provide the structure $form['#submit] and throws a PHP error when the $form['action']['submit] structure is used. This issue is being encountered by using the Context β†’ module.

See elogger.module line 87.

// Skip the elogger exposed form from elogging events triggering.
  if ($form['#id'] != $elogger_exposed_form) {
    array_unshift($form['#submit'], '_add_form_submit_log');
  }
}

Steps to reproduce

  1. Install the Context module.
  2. Add a Condition based on a URL Request.
  3. Add a Reaction to place a Block.
  4. Click the 'Place Block' button to place a block in a region.

Result:The "Place Button" form submit causes the Event Logger module to throw a PHP error:
TypeError: array_unshift(): Argument #1 ($array) must be of type array, null given in array_unshift() (line 87 of /Users/myuser/Sites/mysite/docroot/modules/contrib/elogger/elogger.module)

Proposed resolution

Review the Forms API and Forms AJAX API to determine the correct format, OR, modify the conditional statement to handle multiple form array formats.

https://www.drupal.org/docs/drupal-apis/form-api/introduction-to-form-api β†’

https://www.drupal.org/docs/drupal-apis/javascript-api/ajax-forms β†’

πŸ› Bug report
Status

Fixed

Version

1.1

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States kbaringer

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024