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
This commit is contained in:
Weston Ruter
2025-11-06 22:24:37 +00:00
parent 3c1910c436
commit 680a0856ee
2 changed files with 6 additions and 2 deletions

View File

@@ -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 ) {

View File

@@ -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.