Skip to content

Conversation

@kenjis
Copy link
Member

@kenjis kenjis commented Oct 1, 2022

Description
Fixes #6512

Make the same as Cache Redis config.

public $redis = [
'host' => '127.0.0.1',
'password' => null,
'port' => 6379,
'timeout' => 0,
'database' => 0,
];

Ref, https://github.com/phpredis/phpredis#php-session-handler

Checklist:

  • Securely signed commits
  • Component(s) with PHPDoc blocks, only if necessary or adds value
  • Unit testing, with >80% coverage
  • User guide updated
  • Conforms to style guide

@kenjis kenjis added the bug Verified issues on the current code behavior or pull requests that will fix them label Oct 1, 2022
Copy link
Member

@MGatner MGatner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Really great test case! One change to consider.

'database' => preg_match('#database=(\d+)#', $matches[3], $match) ? (int) $match[1] : null,
'timeout' => preg_match('#timeout=(\d+\.\d+)#', $matches[3], $match) ? (float) $match[1] : null,
'database' => preg_match('#database=(\d+)#', $matches[3], $match) ? (int) $match[1] : 0,
'timeout' => preg_match('#timeout=(\d+\.\d+)#', $matches[3], $match) ? (float) $match[1] : 0,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be 0.0?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the regex should also be updated to check for int timeouts.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

{
parent::setUp();

if (! class_exists(Redis::class)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about moving this to setUpBeforeClass? Or, using a class docblock instead, like @requires extension redis?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, thanks. It is better.
Done.

@kenjis kenjis force-pushed the fix-redis-session-php81 branch from 328fa6c to d97d217 Compare October 5, 2022 02:46
@kenjis kenjis requested review from MGatner and paulbalandan October 5, 2022 02:48
Copy link
Member

@MGatner MGatner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👌

*/
class RedisHandler extends BaseHandler
{
private const REDIS_DEFAULT_PORT = 6379;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
private const REDIS_DEFAULT_PORT = 6379;
private const DEFAULT_PORT = 6379;

What about RedisHandler::DEFAULT_PORT?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, REDIS_ is not needed.
Done.

@kenjis kenjis merged commit 15fa3f1 into codeigniter4:develop Oct 6, 2022
@kenjis kenjis deleted the fix-redis-session-php81 branch October 6, 2022 00:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Verified issues on the current code behavior or pull requests that will fix them

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: Redis::connect(): Passing null to parameter #3 ($timeout) of type float is deprecated

5 participants