PHP 8.1 compatibility

Created on 1 September 2022, over 2 years ago
Updated 23 February 2023, almost 2 years ago

Problem/Motivation

PHP 8.1 updates are imminent (Acquia will stop providing PHP 7.4 next month).

With PHP 8.1 Advpoll produces this error when trying to vote:
TypeError: array_filter(): Argument #1 ($array) must be of type array, string given in array_filter() (line 171 of /var/www/html/docroot/modules/contrib/advpoll/src/Form/ApprovalPollViewForm.php)

With PHP 7.4 it was just a warning:
Warning: array_filter() expects parameter 1 to be array, string given in Drupal\advpoll\Form\ApprovalPollViewForm->validateVote() (line 172 of /var/www/html/docroot/modules/contrib/advpoll/src/Form/ApprovalPollViewForm.php)

Steps to reproduce

Use PHP 8.1
Create a poll
Submit a vote

Proposed resolution

$form_state->getValue('choice') always returns a string (at least in my case), but PHP expects an array.
I see 2 options here:
1. remove array_filter if it is not needed
or
2. provide an array to array_filter

Remaining tasks

Fix it so that we get compatible with PHP 8.1

πŸ› Bug report
Status

RTBC

Version

1.0

Component

Code

Created by

πŸ‡¬πŸ‡·Greece bserem

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