Problem/Motivation

Unfortunately, we've still got some clients on Drupal 9. The latest two releases for mailchimp 2.x in late July introduced an undeclared dependency on a newer version of GuzzleHTTP that wasn't backward compatible, resulting in the following error when we did our monthly updates:

The website encountered an unexpected error. Please try again later.
Error: Call to undefined method GuzzleHttp\Utils::defaultUserAgent() in _mailchimp_get_user_agent() (line 79 of modules/contrib/mailchimp/mailchimp.module).

Steps to reproduce

Upgrade any D9 site to mailchimp 2.2.6 or newer.

Proposed resolution

The workaround was to revert to 2.2.5. mailchimp.module contains the following code at line 79:

$user_agent = "DrupalMailchimp/$version " . Utils::defaultUserAgent();

Prior to that, it was this:

$user_agent = "DrupalMailchimp/$version " . default_user_agent();

We need some kind of wrapper on that to determine whether the new method exists before attempting to use it, falling back to the old one if it does not (or vice versa).

Remaining tasks

Write a patch (I'm on it). 🤣

User interface changes

API changes

Data model changes

Issue fork mailchimp-3542646

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

seanr created an issue. See original summary.

seanr’s picture

Status: Active » Needs review

OK, this should do it.

seanr’s picture

StatusFileSize
new697 bytes

"Just the patch, ma'am." 😂

seanr’s picture

StatusFileSize
new696 bytes
seanr’s picture

These errors don't read like anything of mine (I barely touched anything 🤣) - gonna need some input on this, but I wonder if these were failing already?

1) Drupal\Tests\mailchimp_lists\Functional\MailchimpListsTest::testGetList
Attempt to read property "id" on bool
/builds/issue/mailchimp-3542646/modules/mailchimp_lists/tests/src/Functional/MailchimpListsTest.php:27
/builds/issue/mailchimp-3542646/vendor/phpunit/phpunit/src/Framework/TestResult.php:729
2) Drupal\Tests\mailchimp_signup\Functional\MailchimpSignupFormTest::testSignUpForm
Behat\Mink\Exception\ElementNotFoundException: Form field with id|name|label|value "mc_lists[57afe96172]" not found.
/builds/issue/mailchimp-3542646/vendor/behat/mink/src/WebAssert.php:731
/builds/issue/mailchimp-3542646/web/core/tests/Drupal/Tests/UiHelperTrait.php:90
/builds/issue/mailchimp-3542646/modules/mailchimp_signup/tests/src/Functional/MailchimpSignupFormTest.php:65
/builds/issue/mailchimp-3542646/vendor/phpunit/phpunit/src/Framework/TestResult.php:729
3) Drupal\Tests\mailchimp_signup\Functional\MailchimpSignupFormTest::testEditSignUpForm
Behat\Mink\Exception\ResponseTextException: The text "Signup Forms" was not found anywhere in the text of the current page.
/builds/issue/mailchimp-3542646/vendor/behat/mink/src/WebAssert.php:907
/builds/issue/mailchimp-3542646/vendor/behat/mink/src/WebAssert.php:293
/builds/issue/mailchimp-3542646/web/core/tests/Drupal/Tests/WebAssert.php:979
/builds/issue/mailchimp-3542646/modules/mailchimp_signup/tests/src/Functional/MailchimpSignupFormTest.php:135
/builds/issue/mailchimp-3542646/vendor/phpunit/phpunit/src/Framework/TestResult.php:729
4) Drupal\Tests\mailchimp_signup\Functional\MailchimpSignupFormTest::testSubscribeWithMinimalConfiguredSignUpForm
Behat\Mink\Exception\ElementNotFoundException: Button with id|name|label|value "Sign up" not found.
/builds/issue/mailchimp-3542646/web/core/tests/Drupal/Tests/WebAssert.php:158
/builds/issue/mailchimp-3542646/web/core/tests/Drupal/Tests/UiHelperTrait.php:83
/builds/issue/mailchimp-3542646/modules/mailchimp_signup/tests/src/Functional/MailchimpSignupFormTest.php:178
/builds/issue/mailchimp-3542646/vendor/phpunit/phpunit/src/Framework/TestResult.php:729
xenophyle’s picture

Ah, good catch. Will your fix work without the

use function GuzzleHttp\default_user_agent;

line?

The failing tests are not likely to be your fault -- they need a lot of work.

anpel’s picture

I have this error on 9.3.11 using 2.2.7.

The error remains after applying the patch on#5.

anpel’s picture

StatusFileSize
new673 bytes

Here is a patch from #3 that also includes

use function GuzzleHttp\default_user_agent;

  • xenophyle committed 8234d7ed on 2.x authored by seanr
    [#3542646] feat: 2.2.6+ has an undeclared dependency on newer versions...
xenophyle’s picture

Status: Needs review » Fixed

Now that this issue is closed, please review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, please credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.