Skip to content

Commit 511a524

Browse files
Merge branch '5.4' into 6.2
* 5.4: [Cache] Removing null coalescing assignment operator on 5.4 [Cache] Fix storing binary keys when using pgsql [FrameworkBundle] Add missing monolog channel tag for messenger services [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 8562a1d + 05cd1ac commit 511a524

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
@@ -59,7 +59,7 @@ public static function checkIp(string $requestIp, string|array $ips): bool
5959
*/
6060
public static function checkIp4(string $requestIp, string $ip): bool
6161
{
62-
$cacheKey = $requestIp.'-'.$ip;
62+
$cacheKey = $requestIp.'-'.$ip.'-v4';
6363
if (isset(self::$checkedIps[$cacheKey])) {
6464
return self::$checkedIps[$cacheKey];
6565
}
@@ -104,7 +104,7 @@ public static function checkIp4(string $requestIp, string $ip): bool
104104
*/
105105
public static function checkIp6(string $requestIp, string $ip): bool
106106
{
107-
$cacheKey = $requestIp.'-'.$ip;
107+
$cacheKey = $requestIp.'-'.$ip.'-v6';
108108
if (isset(self::$checkedIps[$cacheKey])) {
109109
return self::$checkedIps[$cacheKey];
110110
}

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)