diff --git a/src/Symfony/Component/HttpFoundation/Request.php b/src/Symfony/Component/HttpFoundation/Request.php index db78105cc83cf..c292585063c54 100644 --- a/src/Symfony/Component/HttpFoundation/Request.php +++ b/src/Symfony/Component/HttpFoundation/Request.php @@ -252,12 +252,24 @@ public function initialize(array $query = [], array $request = [], array $attrib public static function createFromGlobals(): static { $request = self::createRequestFromFactory($_GET, $_POST, [], $_COOKIE, $_FILES, $_SERVER); - - if (str_starts_with($request->headers->get('CONTENT_TYPE', ''), 'application/x-www-form-urlencoded') - && \in_array(strtoupper($request->server->get('REQUEST_METHOD', 'GET')), ['PUT', 'DELETE', 'PATCH'], true) + $contentType = $request->headers->get('CONTENT_TYPE', ''); + $method = strtoupper($request->server->get('REQUEST_METHOD', 'GET')); + + if ( + \in_array($method, ['PUT', 'DELETE', 'PATCH'], true) + && ( + str_starts_with($contentType, 'application/x-www-form-urlencoded') + || str_starts_with($contentType, 'multipart/form-data') + ) ) { - parse_str($request->getContent(), $data); - $request->request = new InputBag($data); + if (\PHP_VERSION_ID >= 80400) { + [$post, $files] = request_parse_body(); + $request->request = new InputBag($post); + $request->files = new FileBag($files); + } elseif (str_starts_with($contentType, 'application/x-www-form-urlencoded')) { + parse_str($request->getContent(), $data); + $request->request = new InputBag($data); + } } return $request;