-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[HttpFoundation] Add lock in MockFileSession #39808
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
Conversation
97bab39
to
7e69771
Compare
Given that most session storages don't lock, I'd prefer using a temporary file instead to write atomically. Wdyt? |
I'm not sure to understand. The file have to be kept and reopened between each request.. If we don't care about atomicity, then, |
See #39816 |
#39816 is a good shot at avoiding "hard" errors that can occur when the The more general issue of session locking to avoid soft/logic errors would require that once one process starts a session (= reads session data from disk, memory, whereever), that process would need to hold a write lock on the session data. All other processes trying to read the same session data would have to wait until the first process finished and wrote back the session. That's the way PHP's For a session implementation like the one in Symfony, that would probably be a bigger behavioral change, and it should work the same way for all kinds of session storage for consistency. I am not sure this is feasible. Side note: IIRC, in the context where I reported #39167, we also used the |
I'm not sure we need such advanced behavior in Symfony. Not all adapter provides locking. People can use native php sessions if they want lockig. |
…ge (nicolas-grekas) This PR was merged into the 4.4 branch. Discussion ---------- [HttpFoundation] use atomic writes in MockFileSessionStorage | Q | A | ------------- | --- | Branch? | 4.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | Fix #39167 | License | MIT | Doc PR | - Instead of #39808 Commits ------- 5290e97 [HttpFoundation] use atomic writes in MockFileSessionStorage
This PR locks the files generated by MockFileSession to provide atomic writes.
I'm not sure this should target 4.4.
note: By using flock, the drawback is: files are not deleted on
destroy
.If this is an issue, we could provide a LockRegistry similar to Cache stamped, but the drawback would be the number of concurrent sessions (users) will be limited.