Skip to content

Conversation

@srtfisher
Copy link

As titled.

@GaryJones GaryJones changed the base branch from main to develop November 13, 2025 15:58
@GaryJones
Copy link
Contributor

Thanks for the PR! You're right that get_post_status_object() can return null and we should handle that case.

Why this happens:

get_post_status_object() returns null when the status isn't registered. This can occur in several scenarios:

  • Posts imported from another system with custom statuses that aren't registered in the current install
  • Posts orphaned after a plugin (like Edit Flow) is deactivated, leaving posts with statuses like pitch or assigned that no longer exist
  • Race conditions during plugin activation/deactivation
  • Database inconsistencies

Issue with the current fix:

The current code returns early without a value:

if ( ! is_object( $post_status ) ) {
    return;
}

This effectively returns null, which breaks the display_post_states filter chain. The filter expects $post_states (an array) to be returned so other filters can continue processing. Returning null would cause issues for any subsequent filters.

Suggested fix:

if ( ! is_object( $post_status ) ) {
    return $post_states;
}

This preserves the filter chain while safely skipping our custom status display when the status object isn't available.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants