Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitbe8401b

Browse files
committed
feature#43550 [HttpFoundation] Remove possibility to pass null as $requestIp in IpUtils (W0rma)
This PR was merged into the 6.0 branch.Discussion----------[HttpFoundation] Remove possibility to pass null as $requestIp in IpUtils| Q | A| ------------- | ---| Branch? | 6.0| Bug fix? | no| New feature? | no| Deprecations? | no| Tickets |#43350 (comment)| License | MIT| Doc PR |Removes the code which was deprecated in#43411Commits-------e95e97d Remove possibility to pass null as $requestIp in IpUtils
2 parents4e69ecd +e95e97d commitbe8401b

File tree

4 files changed

+5
-48
lines changed

4 files changed

+5
-48
lines changed

‎UPGRADE-6.0.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ HttpFoundation
123123
* Retrieving non-scalar values using`InputBag::get()` will throw`BadRequestException` (use`InputBad::all()` instead to retrieve an array)
124124
* Passing non-scalar default value as the second argument`InputBag::get()` will throw`\InvalidArgumentException`
125125
* Passing non-scalar, non-array value as the second argument`InputBag::set()` will throw`\InvalidArgumentException`
126+
* Passing`null` as`$requestIp` to`IpUtils::__checkIp()`,`IpUtils::__checkIp4()` or`IpUtils::__checkIp6()` is not supported anymore.
126127

127128
HttpKernel
128129
----------

‎src/Symfony/Component/HttpFoundation/CHANGELOG.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ CHANGELOG
1717
* Retrieving non-scalar values using`InputBag::get()` will throw`BadRequestException` (use`InputBad::all()` instead to retrieve an array)
1818
* Passing non-scalar default value as the second argument`InputBag::get()` will throw`\InvalidArgumentException`
1919
* Passing non-scalar, non-array value as the second argument`InputBag::set()` will throw`\InvalidArgumentException`
20+
* Passing`null` as`$requestIp` to`IpUtils::__checkIp()`,`IpUtils::__checkIp4()` or`IpUtils::__checkIp6()` is not supported anymore.
2021

2122
5.4
2223
---

‎src/Symfony/Component/HttpFoundation/IpUtils.php‎

Lines changed: 3 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,8 @@ private function __construct()
3232
*
3333
* @param string|array $ips List of IPs or subnets (can be a string if only a single one)
3434
*/
35-
publicstaticfunctioncheckIp(?string$requestIp,string|array$ips):bool
35+
publicstaticfunctioncheckIp(string$requestIp,string|array$ips):bool
3636
{
37-
if (null ===$requestIp) {
38-
trigger_deprecation('symfony/http-foundation','5.4','Passing null as $requestIp to "%s()" is deprecated, pass an empty string instead.',__METHOD__);
39-
40-
returnfalse;
41-
}
42-
4337
if (!\is_array($ips)) {
4438
$ips = [$ips];
4539
}
@@ -63,14 +57,8 @@ public static function checkIp(?string $requestIp, string|array $ips): bool
6357
*
6458
* @return bool Whether the request IP matches the IP, or whether the request IP is within the CIDR subnet
6559
*/
66-
publicstaticfunctioncheckIp4(?string$requestIp,string$ip):bool
60+
publicstaticfunctioncheckIp4(string$requestIp,string$ip):bool
6761
{
68-
if (null ===$requestIp) {
69-
trigger_deprecation('symfony/http-foundation','5.4','Passing null as $requestIp to "%s()" is deprecated, pass an empty string instead.',__METHOD__);
70-
71-
returnfalse;
72-
}
73-
7462
$cacheKey =$requestIp.'-'.$ip;
7563
if (isset(self::$checkedIps[$cacheKey])) {
7664
returnself::$checkedIps[$cacheKey];
@@ -114,14 +102,8 @@ public static function checkIp4(?string $requestIp, string $ip): bool
114102
*
115103
* @throws \RuntimeException When IPV6 support is not enabled
116104
*/
117-
publicstaticfunctioncheckIp6(?string$requestIp,string$ip):bool
105+
publicstaticfunctioncheckIp6(string$requestIp,string$ip):bool
118106
{
119-
if (null ===$requestIp) {
120-
trigger_deprecation('symfony/http-foundation','5.4','Passing null as $requestIp to "%s()" is deprecated, pass an empty string instead.',__METHOD__);
121-
122-
returnfalse;
123-
}
124-
125107
$cacheKey =$requestIp.'-'.$ip;
126108
if (isset(self::$checkedIps[$cacheKey])) {
127109
returnself::$checkedIps[$cacheKey];

‎src/Symfony/Component/HttpFoundation/Tests/IpUtilsTest.php‎

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -77,33 +77,6 @@ public function getIpv6Data()
7777
];
7878
}
7979

80-
/**
81-
* @group legacy
82-
*/
83-
publicfunctiontestIpTriggersDeprecationOnNull()
84-
{
85-
$this->expectDeprecation('Since symfony/http-foundation 5.4: Passing null as $requestIp to "Symfony\Component\HttpFoundation\IpUtils::checkIp()" is deprecated, pass an empty string instead.');
86-
$this->assertFalse(IpUtils::checkIp(null,'192.168.1.1'));
87-
}
88-
89-
/**
90-
* @group legacy
91-
*/
92-
publicfunctiontestIp4TriggersDeprecationOnNull()
93-
{
94-
$this->expectDeprecation('Since symfony/http-foundation 5.4: Passing null as $requestIp to "Symfony\Component\HttpFoundation\IpUtils::checkIp4()" is deprecated, pass an empty string instead.');
95-
$this->assertFalse(IpUtils::checkIp4(null,'192.168.1.1'));
96-
}
97-
98-
/**
99-
* @group legacy
100-
*/
101-
publicfunctiontestIp6TriggersDeprecationOnNull()
102-
{
103-
$this->expectDeprecation('Since symfony/http-foundation 5.4: Passing null as $requestIp to "Symfony\Component\HttpFoundation\IpUtils::checkIp6()" is deprecated, pass an empty string instead.');
104-
$this->assertFalse(IpUtils::checkIp6(null,'2a01:198:603:0::/65'));
105-
}
106-
10780
/**
10881
* @requires extension sockets
10982
*/

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp