Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: default values for Session Redis Handler #6614

Merged
merged 12 commits into from
Oct 6, 2022

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.

system/Session/Handlers/RedisHandler.php Outdated Show resolved Hide resolved
'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.

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.

👌

@@ -22,6 +22,8 @@
*/
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