I get a WSOD when I visit campaigns page. Proxy configuration is not taken into consideration. I've checked patch #9 from https://www.drupal.org/project/mailchimp/issues/2852755 but I don't understand why it does not use "http_client_config" variable.

I've fixed it with the following in mailchimp.module file :

$http_options = [
    'timeout' => 60,
  ];

  // Check if there is a proxy
  if ($proxy_server = \Drupal\Core\Site\Settings::get('http_client_config')) {
    $proxy_http = sprintf(
      'tcp://%s',
      preg_replace("(^https?://)", "", $proxy_server['proxy']['http'])
    );
    $proxy_https = sprintf(
      'tcp://%s',
      preg_replace("(^https?://)", "", $proxy_server['proxy']['http'])
    );
    $http_options += [
      'proxy' => [
        'http' => $proxy_http,
        'https' => $proxy_https
      ]
    ];
  }

  $mailchimp = new $classname($api_key, 'apikey', $http_options);

Issue fork mailchimp-2951089

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:

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

progzy created an issue. See original summary.

Guietc’s picture

Version: 8.x-1.6 » 8.x-1.11
Status: Active » Needs review
FileSize
808 bytes

Thanks @progzy for your issue. It works on 8.x-1.11 version.
I add the patch.

samuel.mortenson’s picture

Status: Needs review » Needs work

I think we should replicate how core uses this setting, see \Drupal\Core\Http\ClientFactory::fromOptions:

  public function fromOptions(array $config = []) {
    $default_config = [
      // Security consideration: we must not use the certificate authority
      // file shipped with Guzzle because it can easily get outdated if a
      // certificate authority is hacked. Instead, we rely on the certificate
      // authority file provided by the operating system which is more likely
      // going to be updated in a timely fashion. This overrides the default
      // path to the pem file bundled with Guzzle.
      'verify' => TRUE,
      'timeout' => 30,
      'headers' => [
        'User-Agent' => 'Drupal/' . \Drupal::VERSION . ' (+https://www.drupal.org/) ' . \GuzzleHttp\default_user_agent(),
      ],
      'handler' => $this->stack,
      // Security consideration: prevent Guzzle from using environment variables
      // to configure the outbound proxy.
      'proxy' => [
        'http' => NULL,
        'https' => NULL,
        'no' => [],
      ],
    ];

    $config = NestedArray::mergeDeep($default_config, Settings::get('http_client_config', []), $config);

    return new Client($config);
  }

The tcp:// specific work in this patch is not standard behavior for this setting, but I think merging it into the Guzzle settings for Mailchimp objects makes sense, based on core.

thomscode’s picture

Adding a new patch that simply uses Drupal's proxy settings as they are. This is more in line with how Drupal's "Settings" class works per comment 3.

gcb’s picture

Assigned: Unassigned » aprice42

robertoperuzzo made their first commit to this issue’s fork.

robertoperuzzo’s picture

I'm testing the @thomscode patch #4. I created an "issue fork" and prepared a merge requester in GitLab in order to help the reviewers.

gcb’s picture

Assigned: aprice42 » spncr
stephen-cox’s picture

Re-rolled patch against latest 2.2.2 release.

stephen-cox’s picture

Version: 8.x-1.11 » 2.x-dev
Status: Needs work » Needs review
FileSize
508 bytes

Previous patch didn't work. New patch re-rolled against latest 2.x branch.