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.phpon line 196 and seems to be caused by anarray_merge()function trying to merge anullvalue.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:196It looks like
$field_attsis sometimesnull, which causes this issue in PHP 8+.Suggested Fix:
To prevent this error, I updated the code on line 196 to ensure
$field_attsis 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_attsis 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!
The topic ‘Bug in WPForms Integration – array_merge() TypeError in class-field.php’ is closed to new replies.