[Session] Truncate session file after successful write - #23653
Open
iliaal wants to merge 1 commit into
Open
Conversation
NickSdot
reviewed
Sep 11, 2026
Comment on lines
+50
to
+53
| foreach (glob($dir . '/sess_*') as $f) { | ||
| @unlink($f); | ||
| } | ||
| @rmdir($dir); |
Contributor
There was a problem hiding this comment.
Add --CLEAN-- and remove the defensive cleanup at the beginning?
Member
Author
There was a problem hiding this comment.
Moved into --CLEAN--. The save path is a fixed name under __DIR__ now so the clean script can find it, which also drops the need for the upfront unlink loop.
Girgias
reviewed
Sep 11, 2026
Comment on lines
+36
to
+37
| pcntl_signal(SIGXFSZ, SIG_IGN); | ||
| var_dump(posix_setrlimit(POSIX_RLIMIT_FSIZE, 16, POSIX_RLIMIT_INFINITY)); |
Member
Author
There was a problem hiding this comment.
It caps the file size so the next session write fails, with SIGXFSZ ignored so the process survives it. The 16 was the wrong number: that gives a short write, which still clobbers the head of the file, so the test could only compare sizes. At 0 nothing lands at all, and the test now compares contents.
The files save handler ftruncated the session file to 0 before writing, so a write that failed returned FAILURE with the previous session data already destroyed. Write first and truncate the old tail to the new length only after the full buffer was written successfully. Sibling audit: PS_WRITE_FUNC/PS_UPDATE_FUNC callers and the read path are unaffected; the empty-write destroy path truncates identically.
iliaal
force-pushed
the
fix/session-write-truncate-84
branch
from
September 11, 2026 11:37
4ca4585 to
870a4b2
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The files session save handler truncated the session file to zero before writing, so a short or failed write returned failure with the previous data already gone. It now writes first and truncates to the new length only after the full buffer lands.