Fatal Error in PHP 8.0 when passing an empty array to a custom checkboxes/select field.
When passing an empty array to a custom Checkboxes (or Select) field, under PHP 8.0 it gives a fatal error: TypeError: mysqli_real_escape_string(): Argument #2 ($string) must be of type string, array given in mysqli_real_escape_string() (line 880 of /app/vendor/pear/db/DB/mysqli.php).
There is no error in PHP 7.4.
Using CiviCRM 5.54.0.
For example:
$results = Address::update()
->addValue(Address_status.Fruit, [])
->addWhere('id', '=', 1)
->execture();
Where Address_status is the custom field group and Fruit is the checkboxes or select field with options.
I am assuming that either the error should be caught earlier by API4 or DAO and warn that empty arrays cannot be passed to this field type, or that it doesn't complain at all and converts the empty array to a serialized string, much like it does with populated arrays.