Skip to content

Fix HTTP status code modification while exception handling (#2027)#2028

Open
tanakahisateru wants to merge 1 commit intoSeldaek:mainfrom
tanakahisateru:fix-status-code-for-exception
Open

Fix HTTP status code modification while exception handling (#2027)#2028
tanakahisateru wants to merge 1 commit intoSeldaek:mainfrom
tanakahisateru:fix-status-code-for-exception

Conversation

@tanakahisateru
Copy link
Copy Markdown

Fixes #2027

The headers_sent() guard does not prevent the E_WARNING from http_response_code(). The warning is emitted when header('HTTP/...') has already been called, but headers_sent() only becomes true after output is flushed to the stream — these are independent states.

headers_list() might seem like an alternative to detect a previously set status line, but it intentionally excludes the HTTP status line.

Dropping the headers_sent() check and suppressing the warning with @ is the most correct approach available: it sets 500 when possible and silently does nothing when it cannot.

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.

E_WARNING from http_response_code() in handleException when a status line has been registered via header() but not yet sent

1 participant