Bug in WPForms Integration – array_merge() TypeError in class-field.php
-
Hi,
I’m experiencing a fatal error when using the Mailchimp for WP and WPForms integration. The issue occurs in
/wp-content/plugins/mailchimp-for-wp/integrations/wpforms/class-field.php
on line 196 and seems to be caused by anarray_merge()
function trying to merge anull
value.Error Message:Fatal error: Uncaught TypeError: array_merge(): Argument #2 must be of type array, null given in /wp-content/plugins/mailchimp-for-wp/integrations/wpforms/class-field.php:196
It looks like
$field_atts
is sometimesnull
, which causes this issue in PHP 8+.Suggested Fix:
To prevent this error, I updated the code on line 196 to ensure
$field_atts
is always treated as an array:Original Code:
$field_atts = array_merge([
'input_class' => [],
'input_id' => [],
], $field_atts);Fixed Code:
$field_atts = array_merge([
'input_class' => [],
'input_id' => [],
], is_array($field_atts) ? $field_atts : []);This change ensures
$field_atts
is always an array, preventing the TypeError.Could you confirm if this is a valid fix and whether an official update will include it? Let me know if you need any additional details.
Thanks!
- You must be logged in to reply to this topic.