Skip to content

Commit dcce1fc

Browse files
Merge branch '6.2' into 6.3
* 6.2: fix merge [DependencyInjection] Filter "container.excluded" services when using `findTaggedServiceIds()` [Cache] Removing null coalescing assignment operator on 5.4 [Console] Add missing ZSH mention in DumpCompletionCommand help [Cache] Fix storing binary keys when using pgsql [FrameworkBundle] Add missing monolog channel tag for messenger services update documentation for telegram bridge notifier [FrameworkBundle] Improve documentation about translation:extract --sort option [VarDumper] Disable links for IntelliJ platform [Notifier] Add bridge documentation [HttpClient] Add hint about `timeout` and `max_duration` options [HttpFoundation] Use separate caches for IpUtils checkIp4 and checkIp6 [FrameworkBundle] Fix wiring session.handler when handler_id is null [FrameworkBundle] Workflow - Fix LogicException about a wrong configuration of "enabled" node
2 parents c689022 + 511a524 commit dcce1fc

File tree

3 files changed

+23
-4
lines changed

3 files changed

+23
-4
lines changed

IpUtils.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ public static function checkIp(string $requestIp, string|array $ips): bool
7474
*/
7575
public static function checkIp4(string $requestIp, string $ip): bool
7676
{
77-
$cacheKey = $requestIp.'-'.$ip;
77+
$cacheKey = $requestIp.'-'.$ip.'-v4';
7878
if (isset(self::$checkedIps[$cacheKey])) {
7979
return self::$checkedIps[$cacheKey];
8080
}
@@ -119,7 +119,7 @@ public static function checkIp4(string $requestIp, string $ip): bool
119119
*/
120120
public static function checkIp6(string $requestIp, string $ip): bool
121121
{
122-
$cacheKey = $requestIp.'-'.$ip;
122+
$cacheKey = $requestIp.'-'.$ip.'-v6';
123123
if (isset(self::$checkedIps[$cacheKey])) {
124124
return self::$checkedIps[$cacheKey];
125125
}

Session/Storage/Handler/NativeFileSessionHandler.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,11 @@ public function __construct(string $savePath = null)
4545
throw new \RuntimeException(sprintf('Session Storage was not able to create directory "%s".', $baseDir));
4646
}
4747

48-
ini_set('session.save_path', $savePath);
49-
ini_set('session.save_handler', 'files');
48+
if ($savePath !== \ini_get('session.save_path')) {
49+
ini_set('session.save_path', $savePath);
50+
}
51+
if ('files' !== \ini_get('session.save_handler')) {
52+
ini_set('session.save_handler', 'files');
53+
}
5054
}
5155
}

Tests/IpUtilsTest.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,21 @@ class IpUtilsTest extends TestCase
1919
{
2020
use ExpectDeprecationTrait;
2121

22+
public function testSeparateCachesPerProtocol()
23+
{
24+
$ip = '192.168.52.1';
25+
$subnet = '192.168.0.0/16';
26+
27+
$this->assertFalse(IpUtils::checkIp6($ip, $subnet));
28+
$this->assertTrue(IpUtils::checkIp4($ip, $subnet));
29+
30+
$ip = '2a01:198:603:0:396e:4789:8e99:890f';
31+
$subnet = '2a01:198:603:0::/65';
32+
33+
$this->assertFalse(IpUtils::checkIp4($ip, $subnet));
34+
$this->assertTrue(IpUtils::checkIp6($ip, $subnet));
35+
}
36+
2237
/**
2338
* @dataProvider getIpv4Data
2439
*/

0 commit comments

Comments
 (0)