Skip to content

ext/json: Stop encoding after a key fails to encode - #374

Closed
iliaal wants to merge 1 commit into
PHP-8.4from
fix/aph-json-encoder-key-escape-success-ba2c-84-work
Closed

iliaal wants to merge 1 commit into
PHP-8.4from
fix/aph-json-encoder-key-escape-success-ba2c-84-work

Conversation

@iliaal

@iliaal iliaal commented Sep 25, 2026

Copy link
Copy Markdown
Owner

Return failure from internal JSON array and object encoders when key escaping fails, while preserving partial-output behavior.

A failure to escape an array or object key was ignored unless
JSON_PARTIAL_OUTPUT_ON_ERROR was set, so encoding went on: later values
still ran user code such as jsonSerialize(), and a later error replaced
the one that was reported, e.g. a NAN value after an invalid UTF-8 key
reported "Inf and NaN cannot be JSON encoded". Both key sites, the
declared-property loop and the property table loop, now return FAILURE
the same way a failed value does.
@iliaal
iliaal force-pushed the fix/aph-json-encoder-key-escape-success-ba2c-84-work branch from 55217ca to 7a0db18 Compare October 4, 2026 19:32
@iliaal iliaal changed the title ext/json: Propagate key escape failures ext/json: Stop encoding after a key fails to encode Oct 4, 2026
@iliaal

iliaal commented Oct 4, 2026

Copy link
Copy Markdown
Owner Author

Submitted upstream as php#24123.

@iliaal iliaal closed this Oct 4, 2026
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.

1 participant