Mailchimp Comment Optin is a plugin we still use for some of our clients. Fixing Outdated Constructor Errors is needed to work with it properly. The error you get will be:

( ! ) Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; MCAPI has a deprecated constructor in /srv/www/domain.com/current/web/app/plugins/mailchimp-comment-optin/lib/classes/MCAPI.class.php on line 3

This refers to an issue with a class name being the same as a function name. This is an old way to add a constructor from back in the days. To deal with that issue on line 39 change:

function MCAPI($apikey, $secure=false) {
 $this->secure = $secure;
 $this->apiUrl = parse_url("http://api.mailchimp.com/" . $this->version . "/?output=php");
 $this->api_key = $apikey; }

to

function __construct($apikey, $secure=false) {
 $this->secure = $secure;
 $this->apiUrl = parse_url("http://api.mailchimp.com/" . $this->version . "/?output=php");
 $this->api_key = $apikey; }

As you see we added __construct and with that you initiate a constructor properly.

NB We recommend not using composer for updates anymore. This so your fixes won’t be removed by an outdated flawed version. Just add the plugin to your ignore list.

Leave a Reply

Your email address will not be published. Required fields are marked *