Michael Dowling is working on a version 4 of Guzzle, which he has informed me should be out "in about a month" (which would be April sometime). Version 3 will still be supported, but he and I both agree that we should plan to upgrade once it's out.
I am marking this postponed for the time being until it's out, but then we can upgrade.
The biggest changes I am aware of that should affect us are:
* It uses its own mini event system rather than the Symfony event dispatcher. (Doesn't hurt us, but we'll have a listener or two to adjust.)
* Curl is no longer a hard requirement, cf #1991298: Fatal error when installing Drupal on servers that don't have the cURL extension
* The mocking plugin will be pulled into the main package, which will deprecate #2209021: Guzzle mock plugin is not included
Nothing really dramatic, so the upgrade should be easy since we're not at RC yet. It should future-proof us better, though.
References:
http://docs.guzzlephp.org/en/guzzle4/
http://docs.guzzlephp.org/en/guzzle4/clients.html#creating-a-client
https://twitter.com/mtdowling/status/440901351657054208 (and following)
Comment | File | Size | Author |
---|---|---|---|
#30 | interdiff-2210637-30.txt | 1.89 KB | damiankloip |
#30 | 2210637-30.patch | 1.48 MB | damiankloip |
Comments
Comment #1
Crell CreditAttribution: Crell commentedComment #2
catchMarked #1991298: Fatal error when installing Drupal on servers that don't have the cURL extension as duplicate.
Bumping to critical, the other issue is only major but combination of small API changes and fixing that major bug tips it over I think.
Comment #3
BerdirWhat does this mean exactly? That it *would* be possible to have an implementation that doesn't use curl or that it will actually provide one out of the box?
Comment #4
tstoecklerFrom the docs there:
Comment #5
mtdowling CreditAttribution: mtdowling commentedGuzzle 4.0.0 stable has been released! See: http://mtdowling.com/blog/2014/03/29/guzzle4/
Comment #6
tstoecklerComment #7
damiankloip CreditAttribution: damiankloip commentedPatch shortly
Comment #8
damiankloip CreditAttribution: damiankloip commentedInitial patch.
I think we might have an issue with this, from core.service.yml:
There are no longer proxy methods like before to the event dispatcher (now emitter). So you cannot add subscribers directly on the client. You now have to use something like:
afaik, we can't do this with calls now. But also not in a service provider etc..
Comment #9
damiankloip CreditAttribution: damiankloip commentedComment #11
damiankloip CreditAttribution: damiankloip commentedOne solution would be to extend the Guzzle Client with our own we can then set our default header option in there instead? Would be good to get your thoughts on the issue above and this solution @mtdowling :)
Comment #13
mtdowling CreditAttribution: mtdowling commentedWhat was the subscriber doing? It sounds like it was adding a header. If that is the case, then I think you can do that in you core.service.yml (here's the PHP code):
$client->setDefaultOption('headers/foo', 'bar');
Comment #14
BerdirYes, but that header is dynamic and based on the function drupal_generate_test_ua(), not sure we can move that to a harcoded method call, maybe if we do it in a service provider?
Comment #15
damiankloip CreditAttribution: damiankloip commentedThis is why I was suggesting moving this logic into an extended class instead. Removing the subscriber. It is unfortunately dynamic so cannot live in a yaml service definition :/
Because right now we can't do a direct port of the logic in guzzle 4.
Comment #16
damiankloip CreditAttribution: damiankloip commentedSome more fixes. Currently it will still be broken, I am seeing this error in the watchdog log:
Comment #17
damiankloip CreditAttribution: damiankloip commentedSome more changes, sorry for the noise! Realised I didn't change most of the use statements. I guess that doesn't help :)
Comment #19
damiankloip CreditAttribution: damiankloip commentedOops, missed some stuff from my local branch in that patch! No wonder there was still some stuff missing... Patches first thing in the morning --
Comment #21
damiankloip CreditAttribution: damiankloip commentedor could we just move everything to our own client, and just merge them as defaults?
Comment #23
damiankloip CreditAttribution: damiankloip commentedOops, we need to keep the simpletest header modification in the subscriber so it fires for each request, not just when the service is first instantiated.
Comment #25
damiankloip CreditAttribution: damiankloip commentedFixed the rest of the ->send() calls when responses are already returned.
Comment #27
damiankloip CreditAttribution: damiankloip commentedThis should fix the other failures/exceptions. Let's see if simpletest will return us some results now. Might still get that weird FATAL error...
Comment #29
damiankloip CreditAttribution: damiankloip commentedComment #30
damiankloip CreditAttribution: damiankloip commentedFixed options.
I think the certificate_authority option is now just 'verify' in Guzzle 4. The default is the bundled Guzzle 4 pem file. So if we override this to TRUE, it will use the system file.
Comment #31
neclimdulI stepped through the code with a debugger since I couldn't make heads or tails of how they where delegating things and coming up with configuration/options. I can confirm 'verify' does as damian said. Can't see anything wrong and some manual testing of aggregator seemed to work well and looking at the changes the look to mostly just contain the API changes.
The only question I have is if it might be possible to avoid including the simpletest listener at all if not needed or have simpletest register it. I didn't look into how feasible that is.
Comment #32
damiankloip CreditAttribution: damiankloip commentedThanks for confirming. Seems we both arrived at the same conclusion which is good :)
I advocated removing this subscriber and only adding it for tests in #2168809: Do not add the Guzzle HTTP client request subscriber outside of test environment. It got a bit of resistance so I would like to just try and get this in, and tackle that there if we can? I would definitely prefer it was only registered for tests though.
Comment #33
sunAwesome. Guzzle++
I reviewed all changes to core and I wasn't able to spot any issues. Looks great to me.
Note that this patch only performs the major upgrade for Guzzle — we'll look into further improvement options (e.g. no longer relying on cURL) in separate issues.
Comment #34
damiankloip CreditAttribution: damiankloip commentedOpened #2237681: Revise Guzzle client configuration and event registration as a follow up to this. There we can discuss how to move forward with event registration etc...
Comment #35
webchickCommitted and pushed to 8.x. Thanks!
Comment #37
tim.plunkettGetting this once in a while now. Seems like Guzzle is the only thing using PSR-4, so posting here.
EDIT: opened #2240803: Composer autoloader possibly out of date
Comment #39
XanoI just stumbled upon this change in contrib and found this issue after digging through the logs. I added a change record to help people discover this change in the future.