• Resolved Jer Clarke

    (@jerclarke)


    Another PHP failure in this plugin which somehow continues to work despite being ignored for years.

    Documenting the issue and fix here for posterity and mostly for my own benefit.

    As of PHP 7.3, a new PHP Warning is issued by the plugin, due to changes in the requirements for the count() function:

    PHP Warning: count(): Parameter must be an array or an object that implements Countable in /[...]/wp-content/plugins/mailchimp/mailchimp.php on line 974

    Basically in previous versions of PHP, you could pass values like false or null to count() and it would treat it as an empty array.

    Now you have to pass an array or you get a warning.

    But the code in mailchimpSF_merge_remove_empty() that triggers the error makes no sense at all:

    
        // If we have an empty $merge, then assign empty string.
        if (count($merge) == 0 || $merge == '') {
            $merge = '';
        }
    

    In this case $merge is ALAWYS an object, and so this will never come into play.

    The fix is to just remove that code. I’ve tested this on sites with and without merge variable and it seems to always work.

  • The topic ‘PHP Warning for merge tags in PHP 7.3 EASY FIX’ is closed to new replies.