- Notifications
You must be signed in to change notification settings - Fork81
fix(auth): selecting database before auth caused error#85
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
base:develop
Are you sure you want to change the base?
Uh oh!
There was an error while loading.Please reload this page.
Conversation
@jasverix Hi! Thank you for the fix! However, without an explanation what error case this is fixing, I'm left guessing a little bit. The general assumption here is that if an object is passed to the constructor, you can just call |
It's a long time since I did this PR, but I am pretty sure it's the Alternative approach is that, in Redis.php, we don't pass |
| } | ||
| if ($database !==null) { | ||
| $this->driver->select($database); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
This causes error if auth is not executed.
| self::$redis =call_user_func(self::$redisServer,self::$redisDatabase); | ||
| }else { | ||
| self::$redis =newRedis(self::$redisServer,self::$redisDatabase); | ||
| self::$redis =newRedis(self::$redisServer,self::$redisDatabase,null,self::$auth); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
This is passing $redisDatabase, which causes a->select() in constructor. Line 78 passes auth after the select.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
What's the value of$redisServer that triggers the error for you?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
The value of $redisServer is10.181.53.75. We are running a local redis server in our network - and that server has auth configured.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
So when $redisServer is set to 10.181.53.75 and $redisDatabase is set to 1, the error occurs. If the $redisDatabase is 0, it does not fail, because ->select() is not ran.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Why not usetcp://user:pass@host:port/db as a value? Theuser part of it is ignored, but that wouldn't be part of$auth either so that wouldn't matter
| self::$redis =newRedis(self::$redisServer,self::$redisDatabase,null,self::$auth); | ||
| } | ||
| if (!empty(self::$auth)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Here, auth is passed, but it is too late.
danhunsakerMar 17, 2025 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Pretty sure theif block after this one should be removed in this PR, since trying toauth twice isn't technically valid.
@danhunsaker You mergedchrisboulton/php-resque#328 that introduced the |
Ultimately, I'd like to rip Credis out and support multiple back ends by making users instantiate their own Redis connection. For now? I'm ok with a rollback. |
331a316 toc38c3e7Compare
No description provided.