[HttpFoundation] Fixes for PHP 8.1 deprecations
This commit is contained in:
parent
b306bdb524
commit
10be072b2b
@ -292,7 +292,7 @@ class Request
|
||||
{
|
||||
$request = self::createRequestFromFactory($_GET, $_POST, [], $_COOKIE, $_FILES, $_SERVER);
|
||||
|
||||
if (0 === strpos($request->headers->get('CONTENT_TYPE'), 'application/x-www-form-urlencoded')
|
||||
if (0 === strpos($request->headers->get('CONTENT_TYPE', ''), 'application/x-www-form-urlencoded')
|
||||
&& \in_array(strtoupper($request->server->get('REQUEST_METHOD', 'GET')), ['PUT', 'DELETE', 'PATCH'])
|
||||
) {
|
||||
parse_str($request->getContent(), $data);
|
||||
@ -1391,7 +1391,7 @@ class Request
|
||||
*/
|
||||
public function getContentType()
|
||||
{
|
||||
return $this->getFormat($this->headers->get('CONTENT_TYPE'));
|
||||
return $this->getFormat($this->headers->get('CONTENT_TYPE', ''));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1564,7 +1564,7 @@ class Request
|
||||
*/
|
||||
public function getETags()
|
||||
{
|
||||
return preg_split('/\s*,\s*/', $this->headers->get('if_none_match'), -1, \PREG_SPLIT_NO_EMPTY);
|
||||
return preg_split('/\s*,\s*/', $this->headers->get('if_none_match', ''), -1, \PREG_SPLIT_NO_EMPTY);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1790,13 +1790,13 @@ class Request
|
||||
*/
|
||||
protected function prepareBaseUrl()
|
||||
{
|
||||
$filename = basename($this->server->get('SCRIPT_FILENAME'));
|
||||
$filename = basename($this->server->get('SCRIPT_FILENAME', ''));
|
||||
|
||||
if (basename($this->server->get('SCRIPT_NAME')) === $filename) {
|
||||
if (basename($this->server->get('SCRIPT_NAME', '')) === $filename) {
|
||||
$baseUrl = $this->server->get('SCRIPT_NAME');
|
||||
} elseif (basename($this->server->get('PHP_SELF')) === $filename) {
|
||||
} elseif (basename($this->server->get('PHP_SELF', '')) === $filename) {
|
||||
$baseUrl = $this->server->get('PHP_SELF');
|
||||
} elseif (basename($this->server->get('ORIG_SCRIPT_NAME')) === $filename) {
|
||||
} elseif (basename($this->server->get('ORIG_SCRIPT_NAME', '')) === $filename) {
|
||||
$baseUrl = $this->server->get('ORIG_SCRIPT_NAME'); // 1and1 shared hosting compatibility
|
||||
} else {
|
||||
// Backtrack up the script_filename to find the portion matching
|
||||
@ -1836,7 +1836,7 @@ class Request
|
||||
$truncatedRequestUri = substr($requestUri, 0, $pos);
|
||||
}
|
||||
|
||||
$basename = basename($baseUrl);
|
||||
$basename = basename($baseUrl ?? '');
|
||||
if (empty($basename) || !strpos(rawurldecode($truncatedRequestUri), $basename)) {
|
||||
// no match whatsoever; set it blank
|
||||
return '';
|
||||
@ -1987,7 +1987,7 @@ class Request
|
||||
*/
|
||||
public function isFromTrustedProxy()
|
||||
{
|
||||
return self::$trustedProxies && IpUtils::checkIp($this->server->get('REMOTE_ADDR'), self::$trustedProxies);
|
||||
return self::$trustedProxies && IpUtils::checkIp($this->server->get('REMOTE_ADDR', ''), self::$trustedProxies);
|
||||
}
|
||||
|
||||
private function getTrustedValues(int $type, string $ip = null): array
|
||||
|
@ -9,4 +9,4 @@ $str = '?*():@&+$/%#[]';
|
||||
$r->headers->setCookie(new Cookie($str, $str, 0, '/', null, false, false, true, null));
|
||||
$r->sendHeaders();
|
||||
|
||||
setrawcookie($str, $str, 0, '/', null, false, false);
|
||||
setrawcookie($str, $str, 0, '/', '', false, false);
|
||||
|
@ -446,7 +446,7 @@ class RequestTest extends TestCase
|
||||
public function getFormatToMimeTypeMapProviderWithAdditionalNullFormat()
|
||||
{
|
||||
return array_merge(
|
||||
[[null, [null, 'unexistent-mime-type']]],
|
||||
[[null, ['unexistent-mime-type']]],
|
||||
$this->getFormatToMimeTypeMapProvider()
|
||||
);
|
||||
}
|
||||
|
Reference in New Issue
Block a user