Problem/Motivation
Drupal 10 will require Guzzle 7.
Goutte has a conflict with Guzzle7, but has already been deprecated as a core dependency in #3176655: Deprecate GoutteDriver use in core and use Behat\Mink\Driver\BrowserKitDriver directly instead and will be removed in #3187315: Remove mink-goutte-driver as a core dependency.
Proposed resolution
Update to Guzzle 7.
Remaining tasks
Steps to recreate this MR (which is easier than rebasing it) follow. Use the latest branch of the Goutte issue.
git remote add drupal-3187315 git@git.drupal.org:issue/drupal-3187315.git
git fetch drupal-3187315
git checkout -b '3187315-9.3-goutte' --track drupal-3187315/'3187315-9.3-goutte'
git checkout -b 3104353-9.3-guzzle
rm -rf vendor
composer install
- Increase the constraint for Guzzle in
core/composer.json
to the latest stable version. COMPOSER_ROOT_VERSION=9.3.x-dev composer update drupal/core guzzlehttp/guzzle
git commit -am "COMPOSER_ROOT_VERSION=9.3.x-dev composer update drupal/core guzzlehttp/guzzle."
git push --set-upstream drupal-9.3-3104353 HEAD
User interface changes
N/A
API changes
N/A
Data model changes
N/A
Release notes snippet
Guzzle has been updated to Guzzle 7.3.0. It requires psr/http-client
1.0.1, which has also been added as a dependency.
Comment | File | Size | Author |
---|---|---|---|
#85 | 3104353-85-interdiff.txt | 4.84 KB | kim.pepper |
#85 | 3104353-85.patch | 13.67 KB | kim.pepper |
|
Issue fork drupal-3104353
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
Comment #2
xjmComment #3
TravisCarden CreditAttribution: TravisCarden at Acquia commentedPatch attached. Let's see what happens.
Comment #4
BerdirYou also need to update the lock file.
Comment #5
TravisCarden CreditAttribution: TravisCarden at Acquia commentedThanks, @Berdir. I just realized that. But doing that yields unexpected results. Here's my exact process beginning with the current 9.0.x branch (with select output):
So to summarize:
guzzlehttp/guzzle
gets installed incore/
withOUT unexpected side effects.guzzlehttp/guzzle
gets installed in the root directory WITH unexpected side effects.There's nothing in the
composer update --lock
output that mentionsjquery-once
, as an example of the unexpected file changes. There's clearly something going on here that I'm not familiar with--perhaps in the Composer plugins. Can someone enlighten me?Comment #6
longwaveComposer gets confused about versions in this case and you need to set COMPOSER_ROOT_VERSION when updating. See https://www.drupal.org/node/3089540 for more info.
However it looks like we can't upgrade yet anyway because of another dependency which is locked to Guzzle 6:
Goutte 4 looks like it drops the Guzzle requirement and uses Symfony HttpClient instead, but in turn behat/mink-goutte-driver will have to support Goutte 4.
Comment #7
TravisCarden CreditAttribution: TravisCarden at Acquia commentedThanks for explaining my Composer issue, @longwave!
Comment #8
TravisCarden CreditAttribution: TravisCarden at Acquia commentedSo as @longwave says, upgrading for real is blocked by
fabpot/goutte:3.x
. Digging a little deeper,fabpot/goutte:4.x
removes the Guzzle requirement altogether (and, in fact, does nothing other than that), so if we could upgrade to that, it would unblock us. Unfortunately, we only getfabpot/goutte
as a requirement ofbehat/mink-goutte-driver
, which pins tofabpot/goutte:3.x
in the latest release. I've submitted a pull request to update its constraint, which would unblock us longterm. I'll report back here with any updates.In the meantime, I'd like to see what the testbot says if we trick Composer into installing Guzzle 7.0.0-beta1. This patch is not committable.
Comment #9
TravisCarden CreditAttribution: TravisCarden at Acquia commentedI confirmed that the testbot installed the correct version of Guzzle:
15:06:58 - Updating guzzlehttp/guzzle (6.5.2 => 7.0.0-beta.1): Downloading (100%)
(See full log.)And the tests pass. If this issue is purely exploratory, I guess we can close it--in which case, I assume we'll create a separate issue to actually commit a fix once Guzzle has a stable 7.x release and we're unblocked upstream.
Comment #10
xjmComment #11
tedbowI look at the build artifacts https://dispatcher.drupalci.org/job/drupal_patches/28337/artifact/jenkin...
and confirmed it install guzzle 7.0.0-beta1 .
Uploading the composer-installed.json to show this
I also applied the patch and did
I then confirmed that guzzle 7.0.0-beta1 was also installed locally.
Since this patch is not going to be committed I don't know if I should close it or mark it RTBC. Marking it as RTBC since we have proven that 7.0.0-beta1 which is the latest release will not break any of our tests.
Comment #12
TravisCarden CreditAttribution: TravisCarden at Acquia commentedComment #13
xjmWhat would the next steps be for Guzzle 7 compatibility? Are there other deprendcies we should consider updating? If do they should make have their own issues.
Comment #14
longwaveAs #8 says, we are blocked by our dependency on
behat/mink-goutte-driver
which depends onfabpot/goutte:3.x
which in turn depends onguzzlehttp/guzzle:6.x
.https://github.com/minkphp/MinkGoutteDriver/pull/80 should resolve this, but upstream need help in getting the tests to run (let alone pass) before this can be merged.
Another option would be convince @fabpot to release a new version of
fabpot/goutte:3.x
which works with both Guzzle 6 and 7.Comment #15
xjmThanks for working on this issue. Still no new beta/RC/release from Guzzle. (The patch also no longer applies.) Therefore, I think postponed is the most accurate status. We were hoping we'd get Guzzle 7 before our RC, but looks like that's not happening.
So, I'm moving to 9.1.x. We can't/shouldn't actually bump the Guzzle requirement from 6 to 7 in a minor, but we can test it once stable and ensure we're forward-compatible for it for D10.
Comment #16
xjmGuzzle 7.0.0 has been released, so we should create a new patch and test against the stable release.
Comment #17
andypostGuess it will allow testing
COMPOSER_ROOT_VERSION=9.1.x-dev composer require guzzlehttp/guzzle '7.0.0 as 6.5.5'
Comment #18
andypostThere's even 7.0.1
Comment #20
andypost2 failed, something wrong with checksum in tests of composer
Comment #22
xjmUh. Wut? Why the aliasing?
Comment #23
andypostBecause when I used to set
^6.5.5 || ^7.0
it failed because other constraints and I went with alias as previous patchWill check it tomorrow deeper, idea was to make sure that everything pass on 7.x
Comment #24
longwave#14 still stands, our dependencies don't yet support Guzzle 7.
Comment #25
catch#14 seems to be the reason for the test failure, but otherwise that looks like a green run which is very encouraging.
Comment #26
longwaveThe build test doesn't understand version aliasing, there is also what looks like an exception change but hopefully that is straightforward to update, so yes it's looking promising except for the upstream dependency issue!
Comment #28
xjmCleaning up leftover beta targets from 9.0.x. We still need this testing issue for D10.
Comment #29
KapilV CreditAttribution: KapilV as a volunteer and commentedComment #30
KapilV CreditAttribution: KapilV as a volunteer and commentedComment #31
xjmAccording to @Gábor Hojtsy we are deprecating the Goutte driver in #3176655: Deprecate GoutteDriver use in core and use Behat\Mink\Driver\BrowserKitDriver directly instead. That removes the blocker.
Steps to create this patch:
rm -rf vendor
composer install
composer remove behat/mink-goutte-driver
COMPOSER_ROOT_VERSION=9.2.x-dev composer update drupal/core guzzlehttp/guzzle
Comment #33
xjmAight, looks like we've some compatibility issues to resolve:
Plus a test that just needs an update for the change:
Comment #34
xjmI think this will resolve #33.4; points 1-3 still need fixing.
Comment #35
longwave#33.2 just needs the legacy testGetHttpClientGoutte test deleting entirely, as the driver has been removed in this patch.
The other two look like Guzzle has rearranged the exception tree and so we need to change what we catch.
Comment #36
xjmAh yep, first bit of #35 makes sense as simply part of the dep removal. Attached should address that as well, leaving #33.1 and .3.
Comment #39
xjmOh, we need to remove the whole test, not just the one method:
Comment #40
xjmMoved the Goutte removal into its own issue and fixing it up there: #3187315: Remove mink-goutte-driver as a core dependency
Comment #41
xjmOK, let's see if I can make an MR on top of the other issue work nicely...
Comment #43
xjmOK, here we go. This is branched from #3187315: Remove mink-goutte-driver as a core dependency and can be rebased against that issue's branch until it lands, whereupon we rebase against HEAD and git magically resolves everything. 🤞
To keep this up to date:
git revert d9f6ffe
(or whatever the latest commit is to update the constraint).git remote add drupal-3104353 git@git.drupal.org:issue/drupal-3104353.git
git fetch drupal-3104353
git checkout -b '3187315-goutte' --track drupal-3187315/'3187315-goutte'
git checkout 3104353-guzzle
git rebase 3187315-goutte
(and resolve any conflicts).rm -rf vendor
composer install
COMPOSER_ROOT_VERSION=9.2.x-dev composer update drupal/core guzzlehttp/guzzle
git commit -am "Update lockfile and metapackages."
git push --set-upstream drupal-3104353 HEAD
Comment #44
xjmNote that the commit I just pushed might get the Media test passing, but there are other places in HEAD that could be affected and just might be lacking test coverage:
Comment #45
xjmSo that's green, but it's possible the following other places also might need to be changed and just lack test coverage, since they also catch the same exception:
core/tests/Drupal/Tests/DrupalTestBrowser.php
install_retrieve_file()
andinstall_check_localization_server()
locale_translation_http_check()
core/modules/update/src/UpdateFetcher.php
core/modules/aggregator/src/Form/OpmlFeedAdd.php
system_retrieve_file()
core/modules/media/src/OEmbed/ResourceFetcher.php
core/modules/media/src/OEmbed/UrlResolver.php
core/modules/media/src/Plugin/media/Source/OEmbed.php
Both
Guzzle\Exception\RequestException
andGuzzle\Exception\ConnectException
exist in both Guzzle 6 and 7. However, in Guzzle 6,ConnectException
extendsRequestException
, whereas in Guzzle 7 they are siblings (both extendingTransferException
directly) that implement different interfaces. This means that it's also probably safe to backport the simple fixes I made above to D9; it'd just be slightly redundant.So whether we catch both or not might differ on a case-by-case basis. My guess is that in most cases we'll want to catch both because usually all we care about is that the request didn't work and we want to log, handle, or re-throw that. In other cases where something depends on the response,
ConnectException
might not be appropriate. At least one of the cases above (forget which) checked for a null response within thecatch
, so it's possible that spot should actually be refactored a little.Edit: We could also potentially simplify it even more and just catch
TransferException
(the parent) in most cases.Comment #46
xjmGoing to make that change.
Comment #47
xjmI have not changed
DrupalTestBrowser
to useTransferException
, because it re-throws the exception if the response isNULL
, and that's always the case forConnectException
. I also added an additionalcatch
block tolocale_translation_http_check()
since the logic of the existingcatch
relies on methods thatConnectException
no longer has.Comment #48
longwaveThis is looking pretty good, I wonder even if we can commit some of the exception changes now to 9.2.x? It looks like we can go up to TransferException in Guzzle 6 and it would be just as applicable in most if not all cases.
Comment #49
xjm@longwave Yep, my next step if that was green was to make a separate issue to exactly that. And green it is, so doing that now. :)
Comment #50
xjmPosted #3188920: Make Guzzle exception handling forward-compatible with Guzzle 7 which is green and NR!
Comment #51
xjmUgh, please ignore the two branches I pushed by accident there.
Comment #52
xjmRetitling and postponing this now that we have an actual path forward for D10.
Comment #53
xjmComment #54
xjmRebased onto latest 9.2.x and #3187315: Remove mink-goutte-driver as a core dependency.
Comment #55
Gábor HojtsyParenting to the more specific issue.
Comment #56
xjmComment #59
xjmUpdating outdated IS.
Comment #61
xjmComment #62
xjmComment #63
xjmClosed the old MR and rebuilt the new one atop the new branch of #3187315: Remove mink-goutte-driver as a core dependency which was itself rebuilt atop 9.3.x.
Comment #64
catchSo #3224421: [PHP 8.1] Add a shim to Guzzle 6 for PHP 8.1 compatibility is working around Guzzle 6 not wanting to make any non-security commits. That workaround is OK as a stop-gap, but I think it would be better if we enabled installing Guzzle 7 in Drupal 9.
This is still blocked on #3187315: Remove mink-goutte-driver as a core dependency, but going to unpostpone that one and suggest we do it in Drupal 9.
Comment #65
kim.pepperNo longer blocked on #3187315: Remove mink-goutte-driver as a core dependency
Comment #66
MurzGuzzle 7 is required for https://github.com/open-telemetry/opentelemetry-php library to gain modern tracing in Drupal, so with Guzzle 6.x we can't install OpenTelemetry php library. So will be great to have this solved in 9.x branch!
Comment #68
longwaveGood news that the tests are passing in the MR.
Are we going to allow both Guzzle 6 and 7 here, but stay pinned to Guzzle 6 in core-recommended so users can choose not to get the major version bump?
Comment #69
MurzCan anybody describe how can I apply that MR to my Drupal instance?
If I apply it as patch, using "cweagans/composer-patches", composer still don't allow me to install guzzle 7, becase seems it checks dependencies in composer.json before patches are applied.
If I try to download composer package from forked git repo https://git.drupalcode.org/issue/drupal-3104353/-/tree/3104353-9.3-guzzle - it can't download the
drupal/core
package (onlydrupal/drupal
can be installed from git), because that is monorepo, anddrupal/core
is located in./core
subfolder.So, I have no other ideas how can I switch my Drupal installation to that forked version of Drupal core via composer. Maybe anybody can suggest any working method?
Comment #70
xjm@longwave Yes, as per my comment on #3224421-8: [PHP 8.1] Add a shim to Guzzle 6 for PHP 8.1 compatibility we can change our constraint to
"guzzlehttp/guzzle": "^6.5.2 || ^7.3.0",
so that sites can use it, but keepcore-recommended
pinned to Guzzle 6.@Murz Note that Drupal 9 itself will not be updated to use Guzzle 7 as in this issue, because that would be a major version break and violate semver. This is a Drupal 10 readiness issue and onl filed against 9.3.x because 10.0.x is currently only a stub. For help using Composer to override/alias dependencies and such, I would suggest asking in the
#composer
channel in the Drupal Slack.@Taran2L, I do not believe the merge you made was necessary. This branch is periodically rebuilt, but the previous MR was still passing. I'm removing issue credit for this pending an explanation. But thanks for your interest in this issue!
Comment #71
xjmI think a separate issue should be filed for allowing Guzzle 7 in our constraint in D9. This issue is for D10. Thanks!
Comment #72
Taran2L@xjm, your MR was not mergeable anymore due to goutte being removed in 9.3.x. I had to do a force push in order to save time doing rebases. Sorry if that is confusing
Comment #73
xjmThanks @Taran2L! For these dependency update issues, it is better to simply merge the non-composer-command commits and then re-run the composer command. I'll try to put instructions in the IS about this. Adding back credit -- thanks for the explanation.
Comment #74
xjmLet's put this in the RTBC queue as a support request like #3044175: [DO NOT COMMIT] Vendor minimum testing issue to get retesting on it. That way we can keep an eye on our Guzzle 7 compatibility.
Comment #75
xjm(For now.)
Comment #76
xjmPosted #3225966: Consider loosening our constraint to allow sites to install Guzzle 6 or 7, or otherwise handle PHP 8.1 deprecations for Guzzle 6.
Comment #77
xjmUnrelatedly, since Guzzle 6 is now security-only, upgrading to Guzzle 7 is now a beta blocker for D10.
Comment #78
catchJust adjusting the title for easier RTBC queue scanning.
Comment #79
catchComment #80
Gábor HojtsyNow that the closer alpha1 requirements issue exists, reparenting to that: #3251854: [META] Requirements for tagging Drupal 10.0.0-alpha1.
Comment #81
alexpottThe MR needs to be updated to be from 10.0.x and the composer conflicts need to be resolved.
Comment #82
longwavePatch for 10.0.x.
Comment #83
alexpottThis issue can remove the guzzle shim and some skipped deprecations too
Comment #84
andypostComment #85
kim.pepper#83 Removes shim and ignored deprecations.
Comment #86
SpokjeIn the last testrun all chromedriver tests failed (Couldn't connect to chromedriver-jenkins-drupal-patches-105182).
Seems highly unlikely that this is related to this MR, so ordered a retest.
Comment #87
Spokje- TestBot turned green
-
guzzlehttp/guzzle
Is updated from6.5.5
to7.4.0
(^6.5.2
=>^7.3.0
)- Shim is removed
- Ignored deprecations removed
RTBC for me.
Comment #88
alexpottCommitted 0ac9613 and pushed to 10.0.x. Thanks!
Comment #90
alexpott