-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[HttpFoundation] Allow RedisCluster class for RedisSessionHandler #28251
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
[HttpFoundation] Allow RedisCluster class for RedisSessionHandler #28251
Conversation
ec7d4aa
to
0ed7dbd
Compare
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.
Thanks
!$redis instanceof \RedisArray && | ||
!$redis instanceof \RedisCluster && | ||
!$redis instanceof \Predis\Client && | ||
!$redis instanceof RedisProxy |
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.
Missing \
, same in the docblock
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.
Do you talk about the RedisProxy class? That one is imported at the top of the class.
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.
Right sorry!
if ( | ||
!$redis instanceof \Redis && | ||
!$redis instanceof \RedisArray && | ||
!$redis instanceof \RedisCluster && |
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.
@nicolas-grekas Just to make things easier to see, this is the condition I added
!$redis instanceof \RedisArray && | ||
!$redis instanceof \RedisCluster && | ||
!$redis instanceof \Predis\Client && | ||
!$redis instanceof RedisProxy |
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.
Right sorry!
This PR was merged into the 3.4 branch. Discussion ---------- [travis] enable Redis cluster | Q | A | ------------- | --- | Branch? | 3.4 | Bug fix? | no | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | - | License | MIT | Doc PR | - Will allow testing #28251 also Commits ------- f245df4 [travis] enable Redis cluster
@michaelperrin I added a Redis cluster in #28255. Can you please rebase and add a test case by taking inspiration from this PR? |
d10fa94
to
08e92bf
Compare
Thank you very much @nicolas-grekas, that is indeed useful to have a Redis cluster for tests. I updated tests in order to use it for tests using I didn't get why an extra To make everything work, I removed the validator in tests and used instead the Maybe you or @dkarlovi will know purpose of the Could you make sure that my changes are alright then? If everything looks fine, I will squash commits into one. |
Validator is supposed to be used to connect to the test version of Redis and confirm the intended action happened regardless of the adapter used. Probably shouldn't be changed, but you be the judge, I'm on mobile. |
@dkarlovi but shouldn't this |
Thanks @dkarlovi for your insight :) I better understand now why you added this other instance. If we decide it is better to keep the "validator" instance, I will override the other methods in the new |
The idea is to have a stand-alone instance which independently confirms the intended action happened. Otherwise the adapter is testing itself and we're supposed to trust it implicitly. |
I agree with this statement, so I'm fine with a single Redis connection personally. |
08e92bf
to
d2ecea0
Compare
Thank you @michaelperrin. |
…Handler (michaelperrin) This PR was squashed before being merged into the 4.1 branch (closes #28251). Discussion ---------- [HttpFoundation] Allow RedisCluster class for RedisSessionHandler | Q | A | ------------- | --- | Branch? | 4.1 <!-- see below --> | Bug fix? | yes | New feature? | no <!-- don't forget to update src/**/CHANGELOG.md files --> | BC breaks? | no <!-- see https://symfony.com/bc --> | Deprecations? | no <!-- don't forget to update UPGRADE-*.md and src/**/CHANGELOG.md files --> | Tests pass? | yes <!-- please add some, will be required by reviewers --> | Fixed tickets | <!-- #-prefixed issue number(s), if any --> | License | MIT | Doc PR | The `RedisSessionHandler` added in Symfony 4.1 was supposed to accept `RedisCluster` instances but that possibility was not in the condition, leading to an `InvalidArgumentException`. I formatted the object type condition to allow the `RedisCluster` instance value and also added a test for it. A double space formatting issue has been fixed too (which is included in the same commit, I can change that if needed). I could not add a test using RedisCluster, as the installed Redis instance on Travis doesn't use clusters. Commits ------- d2ecea0 [HttpFoundation] Allow RedisCluster class for RedisSessionHandler
Thanks @nicolas-grekas for the merge and the help! |
Nice work @michaelperrin! 👍 |
@dkarlovi It is based on your work, so thanks to you ;) |
The
RedisSessionHandler
added in Symfony 4.1 was supposed to acceptRedisCluster
instances but that possibility was not in the condition, leading to anInvalidArgumentException
.I formatted the object type condition to allow the
RedisCluster
instance value and also added a test for it.A double space formatting issue has been fixed too (which is included in the same commit, I can change that if needed).
I could not add a test using RedisCluster, as the installed Redis instance on Travis doesn't use clusters.