After updating core from 7.61 to 7.64 this began to occur on Drupal Commerce checkout:
Error: Unsupported operand types in form_builder() (line 1816 of (...)/includes/form.inc).

I checked the form.inc diff:
form.inc diff

And noticed that is_array() validation was removed.

Note that if the $element parameter comes NULL it won't throw anything because setting $element['#processed'] = FALSE; will "cast" it as an array. But, if the $element comes as, for example, an integer, then we'll have a problem.

Unfortunately I wasn't able to retrieve much information from log.

Probably the is_array() validation should be kept.

Comments

marcofernandes created an issue. See original summary.

marcofernandes’s picture

Status: Active » Needs review
StatusFileSize
new740 bytes

Added a patch to revert the validation code removal.

fred1978’s picture

I had the same error message when upgrading from PHP 5.6 to PHP 7.2 on Drupal 7.64. The error occured when submitting a custom-made form.
Reverting the changes in form.inc as per patch #2 solved the issue.

ebarrette’s picture

I don't know why your form.inc was different, are you sure you did not have a custom patch?

This files hasn't changed between the two version.

https://git.drupalcode.org/project/drupal/blob/7.61/includes/form.inc

https://git.drupalcode.org/project/drupal/blob/7.64/includes/form.inc

We are having the same issue only when using PHP 7.2, haven't tested with 7.1. Works fine with PHP 7.0 and 5.6

marqpdx’s picture

We're having the same issue. In the process of upgrading to 7.66, and the `is_array()` validation is missing, so will break on php 7.1 and 7.2

See here: https://git.drupalcode.org/project/drupal/blob/7.66/includes/form.inc

How can we get that back in? We're on Pantheon and it's extra work to patch core files w/ them.

Am trying downgrading to php 7.0.

thx,
m

ebarrette’s picture

The fix proposed here is a band-aid solution. This is most likely an issue with a contrib/custom module you are using.

When we moved to 7.2 we also started seeing this issue, for us it was this piece of code in a custom implementation of the workbench moderation module.

This line

$form['options']['workbench_moderation_state_new'] = isset($form['revision_information']['workbench_moderation_state_new']) ? $form['revision_information']['workbench_moderation_state_new'] : '';

had to be changed to

$form['options']['workbench_moderation_state_new'] = isset($form['revision_information']['workbench_moderation_state_new']) ? $form['revision_information']['workbench_moderation_state_new'] : array();

Check out these other issues:

https://www.drupal.org/project/workbench_moderation/issues/2871962
https://www.drupal.org/project/entity_pager/issues/2938211

Version: 7.64 » 7.x-dev

Core issues are now filed against the dev versions where changes will be made. Document the specific release you are using in your issue comment. More information about choosing a version.

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.