fix(post): avoid explode(null) deprecation on sparse generate payload - #224
Merged
Merged
Conversation
bordoni
force-pushed
the
fix/post-explode-null-deprecation
branch
2 times, most recently
from
July 16, 2026 14:57
fcfbd15 to
f31038f
Compare
get() returns null when post_parent, html_tags, images_origin or post_types are absent from the request; passing that straight to explode() triggers the PHP 8.1+ 'Passing null to parameter #2' deprecation reported alongside the wp.org critical-error thread. Default these values to an empty string before splitting, with regression coverage for a sparse payload. Refs #221
bordoni
force-pushed
the
fix/post-explode-null-deprecation
branch
from
July 16, 2026 15:01
f31038f to
2a22b9b
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.
Part of the wp.org "a critical error has occurred" report (https://wordpress.org/support/topic/a-critical-error-has-occurred-on-this-site-9/), which logged — alongside the
media_handle_sideload()fatal fixed in #223 — this deprecation:Root cause
get( $request, ... )returnsnullwhenpost_parent,html_tags,images_origin, orpost_typesare absent from the request. Thatnullwas passed straight toexplode(), which is deprecated in PHP 8.1+.Fix
Default each of those request values to an empty string (
get( $request, ..., '' )) beforeexplode(). Because theget()helper usesisset(), the default also covers an explicitly-null value.Tests
PostsEndpointTest::it_should_not_emit_explode_deprecation_on_sparse_payloaddispatches a minimal{quantity: 2}payload with anE_DEPRECATEDhandler installed and asserts noexplode()/null deprecation is emitted.Milestone: 0.9.2