- Issue created by @inascon
- Merge request !10201Issue #3487733: TypeError: array_filter(): Argument #1 ($array) must be of... → (Open) created by sourav_paul
I get this error when submitting a billing profile with a date field, using select list to pick a date.
Use a date field in a billing profile in Drupal Commerce, choose to create a new payment method using this billing profile, and try to complete the checkout process.
The error occurs when the $input argument is empty in the function DateList::checkEmptyInputs($input, $parts). The value of $input can be NULL, which causes the error.
This can be fixed by the following change in line 349 from:
$filtered_input = array_filter($input, 'strlen');
to:
$filtered_input = array_filter($input ?? [], 'strlen');
The function expects $input to be an array, which is apparently not always the case. For example, $input can be explicitly set to NULL during form building in FormBuilder::handleInputElement().