-
-
Notifications
You must be signed in to change notification settings - Fork 6.9k
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
Handle DB session callback custom fields before session closed #17188
Conversation
Doesn't seem to pass tests: https://travis-ci.org/yiisoft/yii2/jobs/501995713 |
This is really hard to fix without BC break. Method I tried 3 attempts to move preparation of custom fields, but there is always some unit test failing. I could update unit tests but it might break backward compatibility if somebody used this feature to set custom session content. Any idea how to fix ? - either introduce minor BC break or leave faulty implementation ? :-) Also - it there guide how to run locally all framework tests? Before pushing the change I would like to run specific tests locally. EDIT: Found guide here |
The tests could be executed with |
That is possible. |
Fail on codeclimate Final fix works, but IMO modifying session data directly via callback should not be allowed, just like it's not possible for FileSession. Users mainly use custom writeCallback fields for tracking who's online or IDs-related stuff etc. It's kinda undocumented dirty feature specific only to DB session :-) |
We may consider disallowing it for 3.0 (sessions will be handled differently there anyway). |
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.
Looks good except minor things.
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.
Is it possible to add unit tests for it?
Unit tests for sessions are already there: |
A test that failed before these changes and isn't failing with these changes. |
There was no failing test before this fix. |
OK, I think it would make sense to add test for new method |
Whooops .. I did not intent to merge anything, |
It's fine to merge master into pull request branch. No issues with it. |
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.
LGTM. Hacky but should work.
Merged. Thank you! |
yiisoft#17188 might brake existing projects when the yii\web\DbSession class is extended.
…kip ci] #17188 might brake existing projects when the yii\web\DbSession class is extended.
…kip ci] yiisoft/yii2#17188 might brake existing projects when the yii\web\DbSession class is extended.
Related to yiisoft/yii2#17559 and yiisoft/yii2#17188.
Attempt to fix #9438, #13740, #15037.
This fixes error
Unkown: Failed to write session data (user)
.Explanation of cause here.
Please review - perhaps somebody might get better idea how to populate fields before closing the session without corrupting the data integrity .. (e.g. if a session variable stored into session field changed between being populated and closing the session). Personally I am not happy with this commit, but so far haven't found better solution :-|