Skip to content

Session: fix session_id('') clear + PHPT headers-sent guards (#17707) - #19226

Merged
PurHur merged 1 commit into
masterfrom
agent/issue-17707-session-phpt-headers-guard
Jul 15, 2026
Merged

PurHur merged 1 commit into
masterfrom
agent/issue-17707-session-phpt-headers-guard

Conversation

@PurHur

@PurHur PurHur commented Jul 15, 2026

Copy link
Copy Markdown
Owner

Summary

  • Fix session_id('') to clear the internal session id while returning the previous id (php-src ext/session/session.c); mirror in JIT SessionId::emitSetFromString empty branch.
  • Refresh 14 stale session compliance PHPT fixtures broken after Regression: session_start() after output — ignores headers-sent guard (ext/session/session.c) #17707 headers-sent guard: add ob_start() or reorder ini_set before output, update session_regenerate_id sid length 32→26, align warning/EXPECT ordering with harness stderr merge.

php-src reference

  • ext/session/session.c — PS(session_id), php_session_start() + SG(headers_sent)

PHP implementation

  • ext/standard/VmSession.php — setId('') clears $id
  • lib/JIT/Builtin/SessionId.php — empty-set clears id buffer
  • test/compliance/cases/stdlib/session*.phpt — headers-sent-safe fixtures

Verification

./script/docker-exec.sh -- bash -lc 'source script/php-env.sh && PHP_COMPILER_PROFILE=8.4 ./vendor/bin/phpunit test/compliance/VMTest.php --filter session'
# OK (45 tests, 45 assertions)

php bin/vm.php test/compliance/cases/stdlib/session_id.phpt
# empty id after session_id('')

Closes #17707 (follow-up: PHPT + session_id('') parity)

Made with Cursor

After #17707, session builtins correctly honor headers_sent like Zend;
stale compliance fixtures echoed before session_start/session_name/ini_set.
Add ob_start() or reorder ini_set before output, align sid_length expect to
26, and fix VmSession::setId('') to clear internal id (JIT mirror).

php-src: ext/session/session.c — PS(session_id), SG(headers_sent)

Verification: PHP_COMPILER_PROFILE=8.4 ./vendor/bin/phpunit test/compliance/VMTest.php --filter session
  # OK (45 tests, 45 assertions)
Co-authored-by: Cursor <cursoragent@cursor.com>
@PurHur
PurHur merged commit 81820ae into master Jul 15, 2026
@PurHur
PurHur deleted the agent/issue-17707-session-phpt-headers-guard branch July 15, 2026 17:05
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.

Regression: session_start() after output — ignores headers-sent guard (ext/session/session.c)

1 participant