From 0ac96136e8b43512962a1974138f89aa9ccd7278 Mon Sep 17 00:00:00 2001
From: Alex Pott <alex.a.pott@googlemail.com>
Date: Fri, 3 Dec 2021 06:24:37 +0000
Subject: [PATCH] Issue #3104353 by xjm, TravisCarden, andypost, kim.pepper,
 longwave, Taran2L, tedbow, catch, alexpott: Upgrade to Guzzle 7

---
 composer.lock                                 | 142 +++++++++++++++---
 .../Metapackage/CoreRecommended/composer.json |   3 +-
 core/composer.json                            |   5 +-
 core/includes/guzzle_php81_shim.php           |  31 ----
 .../Listeners/DeprecationListenerTrait.php    |   5 -
 5 files changed, 127 insertions(+), 59 deletions(-)
 delete mode 100644 core/includes/guzzle_php81_shim.php

diff --git a/composer.lock b/composer.lock
index 19ef7193289f..f7c2660b0d05 100644
--- a/composer.lock
+++ b/composer.lock
@@ -535,7 +535,7 @@
             "dist": {
                 "type": "path",
                 "url": "core",
-                "reference": "5f80d6033e50a621512a12ca2cb2afe9b257f1c1"
+                "reference": "7c4cc1ffebefea56f52ade87488754039b71eaaa"
             },
             "require": {
                 "asm89/stack-cors": "^1.1",
@@ -556,7 +556,7 @@
                 "ext-spl": "*",
                 "ext-tokenizer": "*",
                 "ext-xml": "*",
-                "guzzlehttp/guzzle": "^6.5.2",
+                "guzzlehttp/guzzle": "^7.3.0",
                 "laminas/laminas-diactoros": "^2.1",
                 "laminas/laminas-feed": "^2.12",
                 "masterminds/html5": "^2.1",
@@ -766,8 +766,7 @@
                     "lib/Drupal/Core/Site/Settings.php"
                 ],
                 "files": [
-                    "includes/bootstrap.inc",
-                    "includes/guzzle_php81_shim.php"
+                    "includes/bootstrap.inc"
                 ]
             },
             "scripts": {
@@ -922,37 +921,45 @@
         },
         {
             "name": "guzzlehttp/guzzle",
-            "version": "6.5.5",
+            "version": "7.4.0",
             "source": {
                 "type": "git",
                 "url": "https://github.com/guzzle/guzzle.git",
-                "reference": "9d4290de1cfd701f38099ef7e183b64b4b7b0c5e"
+                "reference": "868b3571a039f0ebc11ac8f344f4080babe2cb94"
             },
             "dist": {
                 "type": "zip",
-                "url": "https://api.github.com/repos/guzzle/guzzle/zipball/9d4290de1cfd701f38099ef7e183b64b4b7b0c5e",
-                "reference": "9d4290de1cfd701f38099ef7e183b64b4b7b0c5e",
+                "url": "https://api.github.com/repos/guzzle/guzzle/zipball/868b3571a039f0ebc11ac8f344f4080babe2cb94",
+                "reference": "868b3571a039f0ebc11ac8f344f4080babe2cb94",
                 "shasum": ""
             },
             "require": {
                 "ext-json": "*",
-                "guzzlehttp/promises": "^1.0",
-                "guzzlehttp/psr7": "^1.6.1",
-                "php": ">=5.5",
-                "symfony/polyfill-intl-idn": "^1.17.0"
+                "guzzlehttp/promises": "^1.5",
+                "guzzlehttp/psr7": "^1.8.3 || ^2.1",
+                "php": "^7.2.5 || ^8.0",
+                "psr/http-client": "^1.0",
+                "symfony/deprecation-contracts": "^2.2"
+            },
+            "provide": {
+                "psr/http-client-implementation": "1.0"
             },
             "require-dev": {
+                "bamarni/composer-bin-plugin": "^1.4.1",
                 "ext-curl": "*",
-                "phpunit/phpunit": "^4.8.35 || ^5.7 || ^6.4 || ^7.0",
-                "psr/log": "^1.1"
+                "php-http/client-integration-tests": "^3.0",
+                "phpunit/phpunit": "^8.5.5 || ^9.3.5",
+                "psr/log": "^1.1 || ^2.0 || ^3.0"
             },
             "suggest": {
+                "ext-curl": "Required for CURL handler support",
+                "ext-intl": "Required for Internationalized Domain Name (IDN) support",
                 "psr/log": "Required for using the Log middleware"
             },
             "type": "library",
             "extra": {
                 "branch-alias": {
-                    "dev-master": "6.5-dev"
+                    "dev-master": "7.4-dev"
                 }
             },
             "autoload": {
@@ -968,28 +975,73 @@
                 "MIT"
             ],
             "authors": [
+                {
+                    "name": "Graham Campbell",
+                    "email": "hello@gjcampbell.co.uk",
+                    "homepage": "https://github.com/GrahamCampbell"
+                },
                 {
                     "name": "Michael Dowling",
                     "email": "mtdowling@gmail.com",
                     "homepage": "https://github.com/mtdowling"
+                },
+                {
+                    "name": "Jeremy Lindblom",
+                    "email": "jeremeamia@gmail.com",
+                    "homepage": "https://github.com/jeremeamia"
+                },
+                {
+                    "name": "George Mponos",
+                    "email": "gmponos@gmail.com",
+                    "homepage": "https://github.com/gmponos"
+                },
+                {
+                    "name": "Tobias Nyholm",
+                    "email": "tobias.nyholm@gmail.com",
+                    "homepage": "https://github.com/Nyholm"
+                },
+                {
+                    "name": "Márk Sági-Kazár",
+                    "email": "mark.sagikazar@gmail.com",
+                    "homepage": "https://github.com/sagikazarmark"
+                },
+                {
+                    "name": "Tobias Schultze",
+                    "email": "webmaster@tubo-world.de",
+                    "homepage": "https://github.com/Tobion"
                 }
             ],
             "description": "Guzzle is a PHP HTTP client library",
-            "homepage": "http://guzzlephp.org/",
             "keywords": [
                 "client",
                 "curl",
                 "framework",
                 "http",
                 "http client",
+                "psr-18",
+                "psr-7",
                 "rest",
                 "web service"
             ],
             "support": {
                 "issues": "https://github.com/guzzle/guzzle/issues",
-                "source": "https://github.com/guzzle/guzzle/tree/6.5"
+                "source": "https://github.com/guzzle/guzzle/tree/7.4.0"
             },
-            "time": "2020-06-16T21:01:06+00:00"
+            "funding": [
+                {
+                    "url": "https://github.com/GrahamCampbell",
+                    "type": "github"
+                },
+                {
+                    "url": "https://github.com/Nyholm",
+                    "type": "github"
+                },
+                {
+                    "url": "https://tidelift.com/funding/github/packagist/guzzlehttp/guzzle",
+                    "type": "tidelift"
+                }
+            ],
+            "time": "2021-10-18T09:52:00+00:00"
         },
         {
             "name": "guzzlehttp/promises",
@@ -1886,6 +1938,58 @@
             },
             "time": "2021-03-05T17:36:06+00:00"
         },
+        {
+            "name": "psr/http-client",
+            "version": "1.0.1",
+            "source": {
+                "type": "git",
+                "url": "https://github.com/php-fig/http-client.git",
+                "reference": "2dfb5f6c5eff0e91e20e913f8c5452ed95b86621"
+            },
+            "dist": {
+                "type": "zip",
+                "url": "https://api.github.com/repos/php-fig/http-client/zipball/2dfb5f6c5eff0e91e20e913f8c5452ed95b86621",
+                "reference": "2dfb5f6c5eff0e91e20e913f8c5452ed95b86621",
+                "shasum": ""
+            },
+            "require": {
+                "php": "^7.0 || ^8.0",
+                "psr/http-message": "^1.0"
+            },
+            "type": "library",
+            "extra": {
+                "branch-alias": {
+                    "dev-master": "1.0.x-dev"
+                }
+            },
+            "autoload": {
+                "psr-4": {
+                    "Psr\\Http\\Client\\": "src/"
+                }
+            },
+            "notification-url": "https://packagist.org/downloads/",
+            "license": [
+                "MIT"
+            ],
+            "authors": [
+                {
+                    "name": "PHP-FIG",
+                    "homepage": "http://www.php-fig.org/"
+                }
+            ],
+            "description": "Common interface for HTTP clients",
+            "homepage": "https://github.com/php-fig/http-client",
+            "keywords": [
+                "http",
+                "http-client",
+                "psr",
+                "psr-18"
+            ],
+            "support": {
+                "source": "https://github.com/php-fig/http-client/tree/master"
+            },
+            "time": "2020-06-29T06:28:15+00:00"
+        },
         {
             "name": "psr/http-factory",
             "version": "1.0.1",
@@ -7920,5 +8024,5 @@
     "platform-overrides": {
         "php": "7.3.0"
     },
-    "plugin-api-version": "2.0.0"
+    "plugin-api-version": "2.1.0"
 }
diff --git a/composer/Metapackage/CoreRecommended/composer.json b/composer/Metapackage/CoreRecommended/composer.json
index 44fece3801c2..1270b2656149 100644
--- a/composer/Metapackage/CoreRecommended/composer.json
+++ b/composer/Metapackage/CoreRecommended/composer.json
@@ -14,7 +14,7 @@
         "doctrine/lexer": "1.2.1",
         "doctrine/reflection": "1.2.2",
         "egulias/email-validator": "3.1.2",
-        "guzzlehttp/guzzle": "6.5.5",
+        "guzzlehttp/guzzle": "7.4.0",
         "guzzlehttp/promises": "1.5.1",
         "guzzlehttp/psr7": "1.8.3",
         "laminas/laminas-diactoros": "2.8.0",
@@ -28,6 +28,7 @@
         "pear/pear_exception": "v1.0.2",
         "psr/cache": "1.0.1",
         "psr/container": "1.1.1",
+        "psr/http-client": "1.0.1",
         "psr/http-factory": "1.0.1",
         "psr/http-message": "1.0.1",
         "psr/log": "1.1.4",
diff --git a/core/composer.json b/core/composer.json
index 2d32788deccd..45a4555f4a14 100644
--- a/core/composer.json
+++ b/core/composer.json
@@ -36,7 +36,7 @@
         "twig/twig": "^2.12.0",
         "doctrine/reflection": "^1.1",
         "doctrine/annotations": "^1.12",
-        "guzzlehttp/guzzle": "^6.5.2",
+        "guzzlehttp/guzzle": "^7.3.0",
         "symfony-cmf/routing": "^2.1",
         "laminas/laminas-feed": "^2.12",
         "stack/builder": "^1.0",
@@ -204,8 +204,7 @@
             "lib/Drupal/Core/Site/Settings.php"
         ],
         "files": [
-            "includes/bootstrap.inc",
-            "includes/guzzle_php81_shim.php"
+            "includes/bootstrap.inc"
         ]
     },
     "config": {
diff --git a/core/includes/guzzle_php81_shim.php b/core/includes/guzzle_php81_shim.php
deleted file mode 100644
index 6b967ee0af88..000000000000
--- a/core/includes/guzzle_php81_shim.php
+++ /dev/null
@@ -1,31 +0,0 @@
-<?php
-
-// phpcs:ignoreFile
-
-namespace GuzzleHttp;
-
-/**
- * Generates URL-encoded query string.
- *
- * This shim exists to make Guzzle 6 PHP 8.1 compatible.
- *
- * @link https://php.net/manual/en/function.http-build-query.php
- *
- * @param object|array $data
- *   May be an array or object containing properties.
- * @param string|null $numeric_prefix
- *   (optional) If numeric indices are used in the base array and this parameter
- *   is provided, it will be prepended to the numeric index for elements in
- *   the base array only.
- * @param string|null $arg_separator [optional] <p>
- *   (optional) arg_separator.output is used to separate arguments, unless this
- *   parameter is specified, and is then used.
- * @param int $encoding_type
- *   (optional) By default, PHP_QUERY_RFC1738.
- *
- * @return string
- *   A URL-encoded string.
- */
-function http_build_query($data, $numeric_prefix = '', $arg_separator = '&', $encoding_type = \PHP_QUERY_RFC1738) {
-  return \http_build_query($data, is_null($numeric_prefix) ? '' : $numeric_prefix, $arg_separator, $encoding_type);
-}
diff --git a/core/tests/Drupal/Tests/Listeners/DeprecationListenerTrait.php b/core/tests/Drupal/Tests/Listeners/DeprecationListenerTrait.php
index 912160732874..6e0c071f880c 100644
--- a/core/tests/Drupal/Tests/Listeners/DeprecationListenerTrait.php
+++ b/core/tests/Drupal/Tests/Listeners/DeprecationListenerTrait.php
@@ -76,9 +76,6 @@ public static function isDeprecationSkipped($message) {
       // issues and thus were not addressed in time for the 9.0.0 release.
       '%The entity link url update for the "\w+" view is deprecated in drupal:9.0.0 and is removed from drupal:10.0.0. Module-provided Views configuration should be updated to accommodate the changes described at https://www.drupal.org/node/2857891.%',
       '%The operator defaults update for the "\w+" view is deprecated in drupal:9.0.0 and is removed from drupal:10.0.0. Module-provided Views configuration should be updated to accommodate the changes described at https://www.drupal.org/node/2869168.%',
-      // Guzzle 6 will not be updated for full PHP 8.1 compatibility, see
-      // https://github.com/guzzle/guzzle/pull/2918.
-      '%Return type of GuzzleHttp\\\\.* should either be compatible with .*, or the #\[\\\\ReturnTypeWillChange\] attribute should be used to temporarily suppress the notice%',
       // Skip EasyRdf deprecations for PHP 8.1 - fixed by
       // https://github.com/easyrdf/easyrdf/pull/384.
       '%Return type of EasyRdf\\\\.* should either be compatible with .*, or the #\[\\\\ReturnTypeWillChange\] attribute should be used to temporarily suppress the notice%',
@@ -136,8 +133,6 @@ public static function getSkippedDeprecations() {
       "The \"PHPUnit\Framework\TestSuite\" class is considered internal This class is not covered by the backward compatibility promise for PHPUnit. It may change without further notice. You should not use it from \"Drupal\Tests\TestSuites\TestSuiteBase\".",
       // PHPUnit 9.
       "The \"PHPUnit\TextUI\DefaultResultPrinter\" class is considered internal This class is not covered by the backward compatibility promise for PHPUnit. It may change without further notice. You should not use it from \"Drupal\Tests\Listeners\HtmlOutputPrinter\".",
-      // Guzzle/PSR-7
-      "Method \"Psr\Http\Message\StreamInterface::getMetadata()\" will return \"mixed\" as of its next major version. Doing the same in implementation \"GuzzleHttp\Psr7\Stream\" will be required when upgrading.",
     ];
   }
 
-- 
GitLab