Skip to content

fix: return $states instead of null in add_unlisted_post_status() - #145

Merged
Nikschavan merged 2 commits into
Nikschavan:masterfrom
kiransbsf:fix/display-post-states-null-return
May 15, 2026
Merged

fix: return $states instead of null in add_unlisted_post_status()#145
Nikschavan merged 2 commits into
Nikschavan:masterfrom
kiransbsf:fix/display-post-states-null-return

Conversation

@kiransbsf

Copy link
Copy Markdown
Contributor

Summary

  • add_unlisted_post_status() has an early-exit path that does a bare return; when viewing the unlisted post filter in wp-admin
  • This returns null instead of $states, breaking the display_post_states WordPress filter chain
  • On PHP 8.x, any downstream plugin with a strict array type hint on this filter receives null and throws a fatal TypeError

Change

 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

kiransbsf added 2 commits May 15, 2026 13:43
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

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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; with return $states; to preserve the filter chain contract.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@Nikschavan
Nikschavan merged commit 48ebf1b into Nikschavan:master May 15, 2026
7 checks passed
@Nikschavan Nikschavan mentioned this pull request May 15, 2026
7 tasks
@kiransbsf
kiransbsf deleted the fix/display-post-states-null-return branch May 18, 2026 07:41
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.

display_post_states filter returns null instead of array — fatal TypeError on PHP 8.x

3 participants