From 28ad9ebbcada2a3c348a408025a3d8647d36bf52 Mon Sep 17 00:00:00 2001 From: tourze Date: Fri, 25 Nov 2022 21:27:18 +0800 Subject: [PATCH] Fix exception when convert Request to string In some application like https://github.com/shopware/platform , they will store some data in cookie by an array struct. It will throw an Exception when we try to log the request. This PR fix it. --- src/Symfony/Component/HttpFoundation/Request.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Component/HttpFoundation/Request.php b/src/Symfony/Component/HttpFoundation/Request.php index f430bfd8869b8..3c73333cbae20 100644 --- a/src/Symfony/Component/HttpFoundation/Request.php +++ b/src/Symfony/Component/HttpFoundation/Request.php @@ -502,7 +502,13 @@ public function __toString(): string $cookies = []; foreach ($this->cookies as $k => $v) { - $cookies[] = $k.'='.$v; + if (is_array($v)) { + foreach ($v as $_k => $_v) { + $cookies[] = "{$k}[{$_k}]={$_v}"; + } + } else { + $cookies[] = $k.'='.$v; + } } if (!empty($cookies)) {