CiviCRM Options fields and PHP 8

Created on 24 January 2023, over 1 year ago
Updated 8 June 2024, 20 days ago

I've come across a couple of problems with CiviCRM Options fields and PHP 8.x.

Instance 1:
~~~~~~
Field set to Static Options but with only a single option enabled.

Throws the following error:

TypeError: array_filter(): Argument #1 ($array) must be of type array, string given in array_filter() (line 726 of ~/httpdocs/web/modules/contrib/webform/src/Plugin/WebformElement/OptionsBase.php)

(Static Options works ok if there is more than one option enabled for the field.)

Instance 2:
~~~~~~
Field set to Live Options, but with no default value set.

Submissions work if a value is provided but give the following error if the field is left incomplete:

TypeError: mysqli_real_escape_string(): Argument #2 ($string) must be of type string, array given in mysqli_real_escape_string() (line 880 of ~/httpdocs/vendor/pear/db/DB/mysqli.php)

Update:
After further investigation I can confirm that this problem only effects the latest version of the module, 6.2.2.

I also notice there are a couple of database upgrades with this version release, the first of which is directly related to Civi Options fields, so would imagine this is connected. Drush output:

webform_civicrm module :
  8004 - Change text state fields to civicrm options.
  8005 - Set Contact 1 as the assigned for Contributions in all webforms (It keeps default behavior
🐛 Bug report
Status

Needs review

Version

6.2

Component

Code

Created by

🇬🇧United Kingdom roblog Cymru

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

Comments & Activities

Production build 0.69.0 2024