Skip to content

[Hash] Improve user hash change detection during request by comparing at the end #543

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

Merged

Conversation

andrerom
Copy link
Contributor

@andrerom andrerom commented Jun 19, 2020

Regarding discussion on user hash change detection, this is what I had in mind:

  • Makes sure we generate hash to compare with on response => In case hash changed during current request
  • Given we only generate hash if ! isAnonymous() as a performance tweak => Still keep track of if user was logged in at request time, in case that changed in the meantime

TODO:

  • Adapt tests (getting a "endTest() : void must be compatible with ..", so we might need to adjust something here due to new mockery / phpunit version)

Copy link
Contributor

@dbu dbu left a comment

Choose a reason for hiding this comment

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

this indeed looks better to me. am i right that previously if the user e.g. was logged out during the request, we would not have detected the hash change?

are we missing (unit) tests for some scenario? thinking of if we have a test that fails with the old implementation and would start to work with this change.

regarding phpunit versions: glad if you have some time to look into it - please do it in a separate pull request to not mix up with this change.

@andrerom
Copy link
Contributor Author

andrerom commented Jul 2, 2020

we would not have detected the hash change?

I think so yes, but besides some random report I don't know for sure if this is the cause or not, it just popped up when auditing the misc code involved as potential problem area.

are we missing (unit) tests for some scenario?

probably, if you are ok with this change overall I'll try to find some time for tests in the next weeks

@dbu
Copy link
Contributor

dbu commented Jul 2, 2020

yes, i do like the change and think it is cleaner than what we had. glad if you can look into a bit of testing to be sure we don't introduce a regression.

@andrerom
Copy link
Contributor Author

On hold for #545

@dbu
Copy link
Contributor

dbu commented Aug 25, 2020

the build in master is fixed, can you please rebase this branch?

@andrerom andrerom force-pushed the user_hash_impr_req_change_detection branch from eec6b70 to b23c0a3 Compare August 25, 2020 13:05
…mparing it at the end

Fix and add test coverage for the PR.
@andrerom andrerom force-pushed the user_hash_impr_req_change_detection branch from b23c0a3 to ec50558 Compare August 25, 2020 13:24
@andrerom
Copy link
Contributor Author

andrerom commented Aug 25, 2020

Done, all tests green 🟢

Failure is on something not related to the changes here:

Exception occurred:
File "/usr/lib/python2.7/dist-packages/sphinx/locale/init.py", line 195, in _
return translators['sphinx'].ugettext(message)
KeyError: 'sphinx'

@dbu
Copy link
Contributor

dbu commented Aug 25, 2020

yep, that failure is known. its the doc build not working. i tried to fix it in FriendsOfSymfony/FOSHttpCache#450 but never found a solution unfortunately.

@dbu dbu merged commit c2c802e into FriendsOfSymfony:master Aug 25, 2020
@dbu
Copy link
Contributor

dbu commented Aug 25, 2020

thanks a lot!

@andrerom andrerom deleted the user_hash_impr_req_change_detection branch August 26, 2020 07:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants