fix: return $states instead of null in add_unlisted_post_status() - #145
Merged
Nikschavan merged 2 commits intoMay 15, 2026
Merged
Conversation
Bare return; on the early-exit path passes null through the display_post_states filter chain. On PHP 8.x, any downstream callback with a strict array type hint (e.g. SureDash) receives null and fatals. Fixes: Nikschavan#144
Bare return; on the early-exit path passes null through the display_post_states filter chain. On PHP 8.x, any downstream callback with a strict array type hint (e.g. SureDash) receives null and fatals. Fixes: Nikschavan#144
There was a problem hiding this comment.
Pull request overview
Fixes a fatal TypeError on PHP 8.x by returning $states instead of an implicit null from the early-exit branch of add_unlisted_post_status(), which is hooked into the display_post_states filter.
Changes:
- Replace bare
return;withreturn $states;to preserve the filter chain contract.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Nikschavan
approved these changes
May 15, 2026
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.
Summary
add_unlisted_post_status()has an early-exit path that does a barereturn;when viewing the unlisted post filter in wp-adminnullinstead of$states, breaking thedisplay_post_statesWordPress filter chainarraytype hint on this filter receivesnulland throws a fatalTypeErrorChange
if ( is_admin() && isset( $_GET['post_status'] ) && 'unlisted' === $_GET['post_status'] ) { - return; + return $states; }Context
Confirmed to cause a fatal crash on PHP 8.1.34 / WordPress 6.9.1 with SureDash installed — the Downloads list page in wp-admin becomes completely inaccessible when browsing
?post_status=unlisted.Closes #144