Skip to content

Commit 33c065f

Browse files
committed
refactor: using filter_var
1 parent 02c8284 commit 33c065f

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

system/Session/Handlers/RedisHandler.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ protected function setSavePath(): void
142142
}
143143
}
144144

145-
$persistent = isset($query['persistent']) ? (bool) $query['persistent'] : null;
145+
$persistent = filter_var($query['persistent'], FILTER_VALIDATE_BOOLEAN) ? (bool) $query['persistent'] : null;
146146
$password = $query['auth'] ?? null;
147147
$database = isset($query['database']) ? (int) $query['database'] : 0;
148148
$timeout = isset($query['timeout']) ? (float) $query['timeout'] : 0.0;

tests/system/Session/Handlers/Database/RedisHandlerTest.php

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,28 @@ public static function provideSetSavePath(): iterable
261261
'persistent' => false,
262262
],
263263
],
264+
'persistent connection with true' => [
265+
'tcp://127.0.0.1:6379?timeout=10&persistent=true',
266+
[
267+
'host' => 'tcp://127.0.0.1',
268+
'port' => 6379,
269+
'password' => null,
270+
'database' => 0,
271+
'timeout' => 10.0,
272+
'persistent' => true,
273+
],
274+
],
275+
'persistent connection with false' => [
276+
'tcp://127.0.0.1:6379?timeout=10&persistent=false',
277+
[
278+
'host' => 'tcp://127.0.0.1',
279+
'port' => 6379,
280+
'password' => null,
281+
'database' => 0,
282+
'timeout' => 10.0,
283+
'persistent' => false,
284+
],
285+
],
264286
];
265287
}
266288
}

0 commit comments

Comments
 (0)