Problem/Motivation
Several contstructors in core use \GuzzleHttp\Client as a signature type, making it impossible to use other client implementations. Unless you extend from the original, but that beats the point of interfaces. So this should be replaced with \GuzzleHttp\ClientInterface.
This is the case for:
- Drupal\system\SecurityAdvisories\SecurityAdvisoriesFetcher
- Drupal\migrate\Plugin\migrate\process\Download
Steps to reproduce
Implement your own httpclient and replace the original. Several errors now occur.
Proposed resolution
Replace the contstructor signatures from \GuzzleHttp\Client to \GuzzleHttp\ClientInterface.
Comments
Comment #2
longwave#3221171: Use ClientInterface in SecurityAdvisoriesFetcher constructor covers one of these cases already.
Comment #3
hmendes commentedAdding a patch to fix the Drupal\migrate\Plugin\migrate\process\Download case.
Comment #4
longwavePatch is straightforward, changing component as this affects migrate only now.
Comment #6
alexpottI've merged #3221171: Use ClientInterface in SecurityAdvisoriesFetcher constructor on commit as this is the same issue and doing in separate issues is not necessary. Crediting @pookmish.
Comment #7
alexpottCommitted cfafb87 and pushed to 9.3.x. Thanks!
Comment #9
bbralaHmm, when #3039047: Adopt php-http/guzzle6-adapter 2.x to get PSR-18 support without losing Guzzle's async support lands, shouldn't this become the generic psr ClientInterface instead of the guzzle specific one? Or do we need guzzle specific features?
Comment #10
alexpott@bbrala yes when that lands we'll need to update things = but atm we're not there yet to so this is making things better, step-by-step.