From 680a0856ee15f909bb0fa5fa8424f7cb364fa972 Mon Sep 17 00:00:00 2001 From: Weston Ruter Date: Thu, 6 Nov 2025 22:24:37 +0000 Subject: [PATCH] Tests: Fix unit test failure in PHP 8.5 due using null as an array offset. This adds `is_string()` type checks for the `$post_status` arg passed to both `get_post_status_object()` and `is_post_status_viewable()`. This was triggered by `Tests_Post_IsPostStatusViewable::test_built_in_and_unregistered_status_types()` for the `null` data set. Follow-up to [61170]. See #63167, #63061. Built from https://develop.svn.wordpress.org/trunk@61171 git-svn-id: http://core.svn.wordpress.org/trunk@60507 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/post.php | 6 +++++- wp-includes/version.php | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/wp-includes/post.php b/wp-includes/post.php index 9e378b9c54..6a0af52436 100644 --- a/wp-includes/post.php +++ b/wp-includes/post.php @@ -1512,7 +1512,7 @@ function register_post_status( $post_status, $args = array() ) { function get_post_status_object( $post_status ) { global $wp_post_statuses; - if ( empty( $wp_post_statuses[ $post_status ] ) ) { + if ( ! is_string( $post_status ) || empty( $wp_post_statuses[ $post_status ] ) ) { return null; } @@ -2455,6 +2455,10 @@ function is_post_type_viewable( $post_type ) { */ function is_post_status_viewable( $post_status ) { if ( is_scalar( $post_status ) ) { + if ( ! is_string( $post_status ) ) { + return false; + } + $post_status = get_post_status_object( $post_status ); if ( ! $post_status ) { diff --git a/wp-includes/version.php b/wp-includes/version.php index 7c888c54be..c87a0582ca 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -16,7 +16,7 @@ * * @global string $wp_version */ -$wp_version = '6.9-beta3-61170'; +$wp_version = '6.9-beta3-61171'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.