Problem/Motivation
when running a scan on php 8.1 deprecation warnings can get triggered during a scan breaking the ajax/json response.
ResponseText: Deprecated: Return type of GuzzleHttp\Cookie\CookieJar::count() should either be compatible with Countable::count(): int, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /app/vendor/guzzlehttp/guzzle/src/Cookie/CookieJar.php on line 220
Deprecated: Return type of GuzzleHttp\Cookie\CookieJar::getIterator() should either be compatible with IteratorAggregate::getIterator(): Traversable, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /app/vendor/guzzlehttp/guzzle/src/Cookie/CookieJar.php on line 225
{"status":true,"percentage":"100","message":"Completed 1 of 1.","label":"Analysis complete for pathauto."}
This is actually a core issue with the version of Guzzle pinned to the D9 release #3225966: Consider loosening our constraint to allow sites to install Guzzle 6 or 7, or otherwise handle PHP 8.1 deprecations for Guzzle 6. Documenting it here to connect the pieces for anyone running into it.
Steps to reproduce
Creating a development environment with PHP 8.1 and error_reporting = E_ALL
Install upgrade_status.
Run a upgrade scan on any module.
Proposed resolution
This can probably only be fixed with a core release.
Remaining tasks
User interface changes
API changes
Data model changes
Comments
Comment #2
neclimdulPostponing since this probably can't be fixed in upgrade_status.
Comment #3
neclimdulcouple updates
1) realized to actually _break_ the batch you need to be using devel and have it disable the error handling. This is the suggested setting for development environments so not too weird still. With the drupal error handler you seem to get a bunch of big red deprecation session messages which is still not great.
2) upgrade status _could_ bypass the code in guzzle triggering the exception by providing its own CookieJar. Turns out its pretty straight forward and seems to work. Patch attached.
Comment #4
akshaydalvi212 commentedHello @neclimdul,
Thanks for the patch,
I will review the patch
Comment #5
akshaydalvi212 commentedHello @neclimdul,
After installing and/or enabling the module using composer command:
composer require 'drupal/upgrade_status:^3.14'.
Using patch #3, it gets applied easily but while scan process it encountered following error:

hence shifting the issue status to needs work.
Thanks and regards.
Comment #6
jaykumar95hey @akshaydalvi212, can you please check the src/CookieJar.php file is created inside this module's folder or not (for mine it's created on root folder).
can you please show commands you run to apply this patch #3?
Comment #7
neclimdulSounds like the failure might have been a problem applying the patch? I'm using this in our upgrade process without the failure.
That said, I need to confirm if this is still needed after the core fix was applied. Maybe still useful if people are using the suggested or which ever project that maintained the tighter requirements.
Comment #8
gábor hojtsyComment #9
gábor hojtsyThere were also existing fails on PHP 7.4 and 8.0 which I just fixed in #3302828: Upgrade Status tests fail on PHP 7.4 and PHP 8.0 due to lack of rules.neon used from phpstan-drupal, so let's run this on all the environments.
Comment #10
gábor hojtsyIn #3302828: Upgrade Status tests fail on PHP 7.4 and PHP 8.0 due to lack of rules.neon used from phpstan-drupal the PHP 8.1 environment was still failing with this error. Providing our own CookieJar sounds like a reasonable stopgap, so let's do this!
Comment #12
gábor hojtsyComment #13
lobodakyrylo commentedNow I get another error:
PHP message: PHP Fatal error: Declaration of Drupal\upgrade_status\CookieJar::withCookieHeader(Psr\Http\Message\RequestInterface $request) must be compatible with GuzzleHttp\Cookie\CookieJarInterface::withCookieHeader(Psr\Http\Message\RequestInterface $request): Psr\Http\Message\RequestInterface in /upgrade_status/src/CookieJar.php on line 28Comment #14
jaykumar95Comment #15
jaykumar95As stated in above patch #3 inside
Drupal\upgrade_status\CookieJar.phpfile if the core haveguzzlehttp/guzzleversion 7, then no need for CookieJar.php in module itself.Comment #16
neclimdul"Can be removed after Core allows Guzzle 7" hmm yeah... it does already? I have questions for me 5 months ago. I'll take a look and see if I can smooth this out.
Comment #17
fgmAs mentioned by lobodacyril, that has now become more severe, actually breaking with today's upgrade_status HEAD, Drupal current stable 9.4.6 and PHP 8.1.10.
Same issue with Drupal 9.5.0-beta1 so not minor, but actually major since it is broken on both a stable version and the upcoming new stable.
Fatal error: Declaration of Drupal\upgrade_status\CookieJar::withCookieHeader(Psr\Http\Message\RequestInterface $request) must be compatible with GuzzleHttp\Cookie\CookieJarInterface::withCookieHeader(Psr\Http\Message\RequestInterface $request): Psr\Http\Message\RequestInterface in /Users/fgm/src/Drupal/d9/drop9/web/modules/contrib/upgrade_status/src/CookieJar.php on line 284Comment #18
fgmComment #19
gábor hojtsySo what do we do then, should we remove our override and depend on which Guzzle the setup takes?
Comment #20
neclimdulI've really wanted to get to this sooner I promise. This is kind of annoying because drupal-recommends still requires guzzle 7. So I guess the "remove later" still makes sense.
Looking at this closer, because of the way types work we can actually just make the signature more specific then the Guzzle 6 interface to match the Guzzle 7 interface and everything should work.
This worked for me but would be could for someone else to verify I didn't miss something.
Comment #21
junglePatch in #20 is not enough for Drupal core 9.5.0-beta2.
Comment #22
jungleUpdated a little bit here
< + ) :void {
---
> + ): void {
Comment #23
rajab natshahFacing the same issue
Switched to test and work with:
Patch in #22 is needed to work in PHP 8.0 and PHP 8.1
Comment #24
rajab natshahIt feels that this issue fix might be better in a new issue.
Comment #25
claudiu.cristeaAny news here? This is a blocker for using the module with PHP 8.1
Comment #26
claudiu.cristeaComment #27
vladimirausDid you try this patch for Guzzle 6.5?
Comment #28
claudiu.cristeaI'm already on PHP 8.1, so Guzzle 7
Comment #30
gábor hojtsySorry for the delay, committed. Will make a release shortly unless there are other pressing things too.
Comment #31
gábor hojtsyhttps://www.drupal.org/project/upgrade_status/releases/8.x-3.18 out now, enjoy! Also please use new issues for followups for better tracking. Thanks a lot!