[php-src] PR #25839: Do not run rfc1867 upload progress cleanup when no file was uploaded
| From: | hohphu8 | Date: | Fri, 27 Nov 2026 14:32:13 +0000 |
| Subject: | [php-src] PR #25839: Do not run rfc1867 upload progress cleanup when no file was uploaded | ||
| Groups: | php.git-pulls | ||
| Request: | Send a blank email to git-pulls+get-41118@lists.php.net to get a copy of this message | ||
Pull Request: https://github.com/php/php-src/pull/25839
Author: hohphu8
In
php_session_rfc1867_callback() (ext/session/session.c),
php_rinit_session(0), PS(id), and PS(send_cookie) = 0 are
only initialized on the first MULTIPART_EVENT_FILE_START event (when
progress->data is allocated). On MULTIPART_EVENT_END, the
else (session.upload_progress.cleanup=0) branch checks
!Z_ISUNDEF(progress->data), but the PS(rfc1867_cleanup) branch does
not.
When a multipart POST carries PHP_SESSION_UPLOAD_PROGRESS and a session ID
cookie/field without any file part, MULTIPART_EVENT_END calls
php_session_rfc1867_cleanup() before RINIT with PS(id) == NULL and
PS(send_cookie) == 1, which creates a new session file on disk and queues a
Set-Cookie header even though user code never calls session_start().
This moves the !Z_ISUNDEF(progress->data) check to the enclosing if so
neither cleanup nor php_rshutdown_session_globals() runs when no upload progress data
was initialized.
Adds ext/session/tests/rfc1867_cleanup_no_file.phpt, which verifies that a multipart
request with PHP_SESSION_UPLOAD_PROGRESS and no file part emits no
Set-Cookie header and creates no session file. Verified FAIL -> PASS on
PHP-8.4 (Debug + ZTS) with ext/session/tests/ passing.
*Found through AI-assisted source inspection, independently reproduced and verified.*