Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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

Open
jasverix wants to merge1 commit intoresque:develop
base:develop
Choose a base branch
Loading
fromjasverix:fix-auth

Conversation

@jasverix
Copy link

No description provided.

@pprkut
Copy link
Collaborator

@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 callauth() before passing it to the constructor. All internal instantiations are handled in the code that's already there, except the case where we instantiateRedis_Cluster, but that would also make sure it's connected to a database in it's__call() method before callingauth().

@jasverix
Copy link
Author

It's a long time since I did this PR, but I am pretty sure it's the$this->driver->select($database); which is directly below the code I added. I cannot run->select() before->auth(), because->select() requires a valid connection.

Alternative approach is that, in Redis.php, we don't passself::$redisDatabase to the constructur, but run->select(self::$redisDatabase) afterif (!empty(self::$auth)) { block.

}

if ($database !==null) {
$this->driver->select($database);
Copy link
Author

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);
Copy link
Author

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.

Copy link
Collaborator

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?

Copy link
Author

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.

Copy link
Author

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.

Copy link
Collaborator

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)) {
Copy link
Author

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.

Copy link
Member

@danhunsakerdanhunsakerMar 17, 2025
edited
Loading

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.

@pprkut
Copy link
Collaborator

@danhunsaker You mergedchrisboulton/php-resque#328 that introduced the$auth. Looking at the code, the way it's implemented i think it actually hurts more than it adds. I'm tempted to just remove it completely again. What do you think? Is there a use case that$auth covers that wouldn't be supported by a DSN string?

@danhunsaker
Copy link
Member

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.

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@pprkutpprkutpprkut left review comments

@danhunsakerdanhunsakerdanhunsaker left review comments

At least 1 approving review is required to merge this pull request.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

3 participants

@jasverix@pprkut@danhunsaker

[8]ページ先頭

©2009-2025 Movatter.jp