Skip to content
Snippets Groups Projects
Commit 1c37073c authored by Ben Di Maggio's avatar Ben Di Maggio
Browse files

Issue #3348969 by bdimaggio: Fatal error: Interface 'Mailchimp\MailchimpApiInterface' not found in

parent 4bcdc694
No related branches found
Tags 7.x-5.7
1 merge request!59Issue #3348969: Fatal error: Interface 'Mailchimp\MailchimpApiInterface' not found in
......@@ -88,15 +88,15 @@ Installation Notes
MailChimp Library Installation
--------------------------------------------------------------------------------
# For MailChimp version 7.x-4.x
# For MailChimp version 7.x-4.x and 7.x-5.x
To use the Libraries module:
- Install the Libraries module:
https://www.drupal.org/project/libraries
- Download the current release of the MailChimp library:
https://github.com/thinkshout/mailchimp-api-php/files/1361112/v1.0.8-package.zip
- Download the latest 2.x (NOT 3.x!) release of the MailChimp library:
https://github.com/thinkshout/mailchimp-api-php/archive/refs/tags/v2.1.3.zip
- Locate your libraries directory. Usually:
/sites/all/libraries/
......@@ -104,6 +104,13 @@ MailChimp Library Installation
- Extract the archive to:
libraries/mailchimp
- Download Composer if you don't already have it installed:
https://getcomposer.org/download/
- In libraries/mailchimp, run composer to get the module's dependencies:
cd sites/all/libraries/mailchimp
composer install
- Ensure the directory structure looks like this:
- libraries/
......
......@@ -10,6 +10,6 @@
"php"
],
"require": {
"thinkshout/mailchimp-api-php": ">=1.0.9"
"thinkshout/mailchimp-api-php": "2.1.3"
}
}
......@@ -99,7 +99,7 @@ function mailchimp_admin_settings() {
}
else {
drupal_set_message(
t('Your Mailchimp library is out of date. Download the <a href="@release">latest v1 release here</a> to make use of the "Connected sites" functionality.', array(
t('Your Mailchimp library version is incorrect. Download the <a href="@release">latest v2 (NOT v3!) release here</a> to make use of the "Connected sites" functionality.', array(
'@release' => 'https://github.com/thinkshout/mailchimp-api-php/releases',
)),
'warning');
......@@ -139,7 +139,7 @@ function mailchimp_admin_settings() {
'#description' => t('Maximum number of entities to process in a single cron run. MailChimp suggest keeping this at 5000 or below. <i>This value is also used for batch Merge Variable updates on the Fields tab (part of mailchimp_lists).</i>'),
'#default_value' => variable_get('mailchimp_batch_limit', 100),
);
$form['mailchimp_api_timeout'] = [
'#type' => 'textfield',
'#title' => t('MailChimp API Timeout'),
......
......@@ -65,10 +65,12 @@ function mailchimp_requirements($phase) {
if (empty($library['error'])) {
$version_int = (int) str_replace('.', '', $library['version']);
if ($version_int <= 107) {
$requirements['mailchimp']['value'] = $library['version'];
$requirements['mailchimp']['description'] = $t('Please update the <a href="https://github.com/thinkshout/mailchimp-api-php/releases">MailChimp library</a> to at least version 1.0.8 to ensure continued stability.');
$requirements['mailchimp']['severity'] = REQUIREMENT_WARNING;
if ($library['version'] != '2.x') {
if ($version_int != 1010 && ($version_int <= 107 || $version_int >= 300)) {
$requirements['mailchimp']['value'] = $library['version'];
$requirements['mailchimp']['description'] = $t('Please !verb the <a href="https://github.com/thinkshout/mailchimp-api-php/releases">MailChimp library</a> to any version between version 1.0.8 and 2.1.3 (inclusive) to ensure continued stability.', array('!verb' => $version_int <= 107 ? 'update' : 'downgrade'));
$requirements['mailchimp']['severity'] = REQUIREMENT_WARNING;
}
}
}
......
......@@ -21,14 +21,27 @@ define('MAILCHIMP_STATUS_SENDING', 'sending');
* Implements hook_libraries_info().
*/
function mailchimp_libraries_info() {
// Set up the version numbers we'll accept. Nothing above 2.1.3.
for ($major = 1; $major < 3; $major++) {
if ($major == 1) {
for ($point_release = 0; $point_release <= 10; $point_release++) {
$versions[$major . '.0.' . $point_release] = array();
}
}
else {
$versions['2.0.1'] = array();
for ($point_release = 0; $point_release <= 3; $point_release++) {
$versions[$major . '.0.' . $point_release] = array();
}
}
}
$libraries['mailchimp'] = array(
'name' => 'MailChimp API',
'vendor url' => 'https://github.com/thinkshout/mailchimp-api-php',
'download url' => 'https://github.com/thinkshout/mailchimp-api-php/releases/download/v1.0.10/v1.0.10-package.zip',
'version arguments' => array(
'file' => 'composer.json',
'pattern' => '/"version": "([0-9a-zA-Z.-]+)"/',
),
'download url' => 'https://github.com/thinkshout/mailchimp-api-php/archive/refs/tags/v2.1.3.zip',
'version callback' => '_mailchimp_get_version',
'versions' => $versions,
'files' => array(
'php' => array(
'src/Mailchimp.php',
......@@ -46,6 +59,29 @@ function mailchimp_libraries_info() {
return $libraries;
}
function _mailchimp_get_version($library) {
// First try to get the 1.x or 3.x versions of the module, which kept version
// number in composer.json.
$version_arguments = array(
'file' => 'composer.json',
'pattern' => '/"version": "([0-9a-zA-Z.-]+)"/',
);
$version = libraries_get_version($library, $version_arguments);
// If that failed, we might have version 2.x, which a) didn't have version
// number in composer.json, and b) incorrectly kept the version number stuck
// at "2.0.0" in src/Mailchimp.php. But at least it's something that tells us
// major version number.
if (empty($version)) {
$version_arguments = array(
'file' => 'src/Mailchimp.php',
'pattern' => "/const VERSION = '([0-9.]+)';/"
);
$version = libraries_get_version($library, $version_arguments) == '2.0.0' ? '2.x' : null;
}
return $version;
}
/**
* Implements hook_menu().
*/
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment