Skip to content

Commit b8e315d

Browse files
ddevsrpaulbalandan
authored andcommitted
refactor: using filter_var
1 parent e168fa1 commit b8e315d

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
@@ -270,6 +270,28 @@ public static function provideSetSavePath(): iterable
270270
'persistent' => false,
271271
],
272272
],
273+
'persistent connection with true' => [
274+
'tcp://127.0.0.1:6379?timeout=10&persistent=true',
275+
[
276+
'host' => 'tcp://127.0.0.1',
277+
'port' => 6379,
278+
'password' => null,
279+
'database' => 0,
280+
'timeout' => 10.0,
281+
'persistent' => true,
282+
],
283+
],
284+
'persistent connection with false' => [
285+
'tcp://127.0.0.1:6379?timeout=10&persistent=false',
286+
[
287+
'host' => 'tcp://127.0.0.1',
288+
'port' => 6379,
289+
'password' => null,
290+
'database' => 0,
291+
'timeout' => 10.0,
292+
'persistent' => false,
293+
],
294+
],
273295
];
274296
}
275297
}

0 commit comments

Comments
 (0)