Skip to content

fix(post): avoid explode(null) deprecation on sparse generate payload - #224

Merged
bordoni merged 1 commit into
mainfrom
fix/post-explode-null-deprecation
Jul 16, 2026
Merged

bordoni merged 1 commit into
mainfrom
fix/post-explode-null-deprecation

Conversation

@bordoni

@bordoni bordoni commented Jul 16, 2026

Copy link
Copy Markdown
Owner

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:

PHP Deprecated: explode(): Passing null to parameter #2 ($string) of type string is deprecated in .../Module/Post.php on line 163

Root cause

get( $request, ... ) returns null when post_parent, html_tags, images_origin, or post_types are absent from the request. That null was passed straight to explode(), which is deprecated in PHP 8.1+.

Fix

Default each of those request values to an empty string (get( $request, ..., '' )) before explode(). Because the get() helper uses isset(), the default also covers an explicitly-null value.

Tests

PostsEndpointTest::it_should_not_emit_explode_deprecation_on_sparse_payload dispatches a minimal {quantity: 2} payload with an E_DEPRECATED handler installed and asserts no explode()/null deprecation is emitted.

Milestone: 0.9.2

@bordoni bordoni added this to the 0.9.2 milestone Jul 16, 2026
@bordoni
bordoni force-pushed the fix/post-explode-null-deprecation branch 2 times, most recently from fcfbd15 to f31038f Compare July 16, 2026 14:57
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
bordoni force-pushed the fix/post-explode-null-deprecation branch from f31038f to 2a22b9b Compare July 16, 2026 15:01
@bordoni
bordoni merged commit d0fb355 into main Jul 16, 2026
3 of 5 checks passed
@bordoni
bordoni deleted the fix/post-explode-null-deprecation branch July 16, 2026 15:03
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