Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
By dawehner on
Change record status:
Published (View all published change records)
Project:
Introduced in branch:
8.0.x
Introduced in version:
8.0.0-beta13
Issue links:
Description:
#2493911: Update guzzle, goutte and mink-goutte-driver to the latest release updated the used guzzle version to guzzle 6.
The main part of that update was the update to use PSR-7 instead of RingPHP.
For usages of the guzzle HTTP client though almost nothing changes, so code like:
$client = \Drupal::client();
$result = $client->get('https://www.drupal.org');
// ...
continues to work. For more documentation around guzzle, read https://guzzle.readthedocs.org/en/latest/
Incompatibilities
There are a couple of incompatibilities.
- You had a custom subscriber. This is now replaced by a middleware approach. So subscribers needs to be tagged with "http_client_middleware" in your services.yml file.
The middleware then needs to implement __invoke() and return a function which takes a handler. For an actual example, please look at\Drupal\Core\Test\EventSubscriber\TestHttpClientMiddleware
. For more information read more on https://guzzle.readthedocs.org/en/latest/handlers-and-middleware.html - You wanted to have a custom connection setting. For that usecase we introduced a new client factory:
http_client_factory
Before
$this->client = \Drupal::httpClient(); $this->client->setDefaultOption('config/curl', array(CURLOPT_TIMEOUT => 10));
After
$this->client = \Drupal::service('http_client_factory') ->fromOptions(['config/curl' => [CURLOPT_TIMEOUT => 10]]);
Impacts:
Module developers