Two fatal errors in PHP 8 fixes

[ad_1]

Hi,
thank you very much for this plugin.

I’ve found two “PHP Fatal error” when using the plugin with the Bitnami WordPress Docker, which uses PHP 8.0.

PHP Fatal error: Uncaught TypeError: array_keys(): Argument #1 ($array) must be of type array, bool given in /bitnami/wordpress/wp-content/plugins/yikes-inc-easy-mailchimp-extender/includes/class-yikes-inc-easy-mailchimp-extender-option-forms.php:37

And

PHP Fatal error: Uncaught TypeError: count(): Argument #1 ($value) must be of type Countable|array, bool given in /bitnami/wordpress/wp-content/plugins/yikes-inc-easy-mailchimp-extender/admin/partials/menu/manage-forms.php:131

They are both related to array management.

The first one could be fixed this way:


// Grab our existing IDs and determine what the next one should be.
$all_ids         = $this->get_form_ids();
$last_id = 0;

if ( is_array( $all_ids ) ) {
	$last_id         = end( $all_ids );
}

$new_id          = false === $last_id ? 1 : $last_id + 1;
$form_data['id'] = $new_id;

And the second one, just checking the $all_forms var is set before counting:

if ( $all_forms && count( $all_forms ) > 0 ) {

There are some WARNINGS, but these two errors made impossible to use the plugin with PHP 8.0.

Hope it helps.

Thanks again 🙂

  • This topic was modified 6 hours, 28 minutes ago by Bolorino.

 

This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer