Hi,

I've just upgraded the mailchimp module in a site - it all seemed to update okay but I've suddenly got this error coming up in my status report:

"The version of the MailChimp API library could not be detected."

I just generated a new API key from Mailchimp and updated it in my module config, but that doesn't seem to have made a difference to the error, but I can't think what else the error might be referring to though as I only have the core module enabled.

Comments

Rhicreate created an issue. See original summary.

GemQueen’s picture

Found this in the README (guess I should always read THAT first, but I almost never do, I WILL from now on. :)
If you are using Libraries module for version 7.x-4.x:

- Download Composer if you don't already have it installed:
https://getcomposer.org/download/

- Download version 1.0.3 of the v3 API library:
https://github.com/thinkshout/mailchimp-api-php/releases

- Extract the library archive to libraries/mailchimp

- Ensure the directory structure looks like this:

- libraries/
- mailchimp/
- src/
- Mailchimp.php
- MailchimpAPIException.php
- MailchimpCampaigns.php
- MailchimpLists.php
- MailchimpReports.php
- MailchimpTemplates.php
- composer.json
- README.md

- In the mailchimp library directory, run:
composer install

NOTE, there doesn't seem to be a way to just plug this in w/o using composer, because if you don't do composer install, you will still get this error: The MailChimp PHP library is missing the required GuzzleHttp library.

Rhicreate’s picture

Yes, I got the PDO Exception too and was unable to run update.php.
However, I was successful at running my update.php after disabling the Mailchimp module - it might be worth logging in to your database to check all the Mailchimp modules are turned off properly in the system table as my admin interface was not behaving as expected trying to do it through the Modules page.

I've tried to re-enable it since running the update but I'm just getting PDO exception errors again - especially on the modules page and administration pages. It's not crashing the site but it is making administration quite difficult. Just looking for an older version to revert for the time being.

ruscoe’s picture

Are you upgrading from a 3.x version of the module? If so, you will need to replace the old mailchimp library with the new one (if you haven't already.)

The new library has some dependencies that are managed using Composer. There's a short installation guide here.

Would you be willing to post the PDO exception you're getting here? We can take a look at it.

GemQueen’s picture

Not everyone uses composer. There needs to be an alternative you can just upload.

Rhicreate’s picture

Thanks for the replies. For reference my PDOException error read as follows:

PDOException: SQLSTATE[42S02]: Base table or view not found: 1146 Table 'cache_mailchimp' doesn't exist: TRUNCATE {cache_mailchimp} ; Array ( ) in cache_clear_all() (line 168 of /includes/cache.inc).

I hadn't installed the library with Composer, so it's probably that. I don't really have time to fix it now though as I don't already have it set up, so I'm just going to leave the functionality off until I do (it's a minor annoyance with regards to this site, not mission critical...).

Like GemQueen, I probably also should've read the ReadMe before updating, but it all seemed to go through Drupal auto-update okay and the alert coincided with another core update so my attention was elsewhere...

ruscoe’s picture

@GemQueen Sorry for the delay in getting back to you. We have been talking internally about the Composer issue and we may either bundle the entire library (plus dependencies) in with the MailChimp module (we do this with the D8 version) or provide a complete package for download via GitHub. I'll run these options past the team again.

@Rhicreate Looks like you're missing a cache table, which likely means something went wrong during the module upgrade. There are two possible ways to fix this:

1) Completely uninstall and reinstall the MailChimp module.

2) If you have access to your database server, you could run this SQL query to create the missing table:

CREATE TABLE `cache_mailchimp` (
  `cid` varchar(255) NOT NULL DEFAULT '' COMMENT 'Primary Key: Unique cache ID.',
  `data` longblob COMMENT 'A collection of data to cache.',
  `expire` int(11) NOT NULL DEFAULT '0' COMMENT 'A Unix timestamp indicating when the cache entry should expire, or 0 for never.',
  `created` int(11) NOT NULL DEFAULT '0' COMMENT 'A Unix timestamp indicating when the cache entry was created.',
  `serialized` smallint(6) NOT NULL DEFAULT '0' COMMENT 'A flag to indicate whether content is serialized (1) or not (0).',
  PRIMARY KEY (`cid`),
  KEY `expire` (`expire`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
Rhicreate’s picture

@Ruscoe Thank you. I was unable to run update.php after updating the module, due to not having installed the library correctly, and that in turn meant the tables weren't updated. I just uninstalled and reinstalled everything from scratch with a clear head and everything's seems to be working perfectly again.

Another aspect of the problem was quite possibly the Webform Mailchimp module I'm using, which I noticed was giving a WSOD after installing the updated version of mailchimp, but a patch is available which has fixed that now too, so I'm all good here :)

Dajia Dim’s picture

@ruscoe Thank you for your solution, but I'm still getting the PDOExceptionI when I try to run update.php.

I completely uninstalled and the reinstalled the Mailchimp module (I did that a couple of times, in two different sites...) but I still have the "PDOException: SQLSTATE[42S02]: Base table or view not found: 1146 Table 'mysite.cache_mailchimp' doesn't exist: TRUNCATE {cache_mailchimp} ; Array ( ) in cache_clear_all() (line 168 of mysite/drupal_site/includes/cache.inc)." (I correctly and successfully have added the new version of the mailchimp library, with composer).

For your second solution, well, not everyone is able to add an extra table that is supposed that is missing.

Any other suggestions....?

ruscoe’s picture

@Dajia Dim I've been trying to reproduce this but so far haven't been able to.

Just to help me follow the same steps as you, could you confirm whether you were originally upgrading from a previous MailChimp release or installing fresh, and which version of the MailChimp module you're installing?

Dajia Dim’s picture

@ruscoe Here's the story...

I have an installation of Drupal core 7.51. The Mailchimp module I need to update was 7.x-2.13. Drupal reported me for two available updates, versions 7.x-3.3 (as security update) and 7.x-4.5.

According to documentation for installing the 7.x-4.5 version of Mailchimp module, I used the version 0.3 of the The Mailchimp library .

I tried both methods:

Upgrade from a previous release

I tried to upgrade the mailchimp module from 7.x-2.13 to 7.x-4.5 and I get the PDO for the missing table

I also tried to upgrade the mailchimp module from 7.x-2.13 to 7.x - 3.3, thinking that the missing table maybe is "hidden" to 7.x - 3.3 version of the module. If that was the case, I then would upgrade to 7.x-4.5. But after the upgrade to 7.x - 3.3, I still get the PDO and the missing table.

Install a fresh new Mailchimp module

I properly uninstalled Mailchimp module version 7.x-2.13 and then I properly installed Mailchimp module version 7.x - 4.5. I still get the PDO message.

I must mention that in every step I was clearing the cache and the error appeared when I wanted run the /update.php page.

I've tried many times, all these methods, in two different sites that use the mailchimp module.

ruscoe’s picture

Thank you for the extra info. That helped me test, but in my case Drupal is always creating the cache_mailchimp table when the module is installed.

I did some research and it looks like this has happened to other modules. The cache table is created by Drupal core, so it makes sense that the same error could occur for modules other then MailChimp.

Here's an example of the same issue with the Rules module: https://www.drupal.org/node/2160645

In the issue above, the accepted solution is creating the table manually. I understand that won't work for you. The issue above contains some interesting links that are worth a look:
https://www.drupal.org/node/2160645#comment-9336675

Unfortunately the general consensus is that at least one SQL command needs to be run on the MySQL server. Either to create the table (as in my earlier comment) to attempt to fix a corrupt table by running REPAIR TABLE cache_mailchimp (if the table exists but still doesn't work).

There is one thing I'd like to ask you to try before running SQL queries. You mentioned you had a problem when using update.php - Instead of update.php, could you run any pending database updates using drush in verbose mode? The drush command would be: drush updb -v

That will show you any errors and warnings that might not appear when using update.php.

pthornhi6’s picture

I fixed this issue by setting my mailchimp library folder permissions to 755. From inside the "sites/all/library/" folder I used the command: chmod -R 755 mailchimp.

samuel.mortenson’s picture

Status: Active » Closed (outdated)