Skip to content

Commit 653e935

Browse files
committed
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. git-svn-id: https://develop.svn.wordpress.org/trunk@61171 602fd350-edb4-49c9-b593-d223f7449a82
1 parent 4db780e commit 653e935

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/wp-includes/post.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1512,7 +1512,7 @@ function register_post_status( $post_status, $args = array() ) {
15121512
function get_post_status_object( $post_status ) {
15131513
global $wp_post_statuses;
15141514

1515-
if ( empty( $wp_post_statuses[ $post_status ] ) ) {
1515+
if ( ! is_string( $post_status ) || empty( $wp_post_statuses[ $post_status ] ) ) {
15161516
return null;
15171517
}
15181518

@@ -2455,6 +2455,10 @@ function is_post_type_viewable( $post_type ) {
24552455
*/
24562456
function is_post_status_viewable( $post_status ) {
24572457
if ( is_scalar( $post_status ) ) {
2458+
if ( ! is_string( $post_status ) ) {
2459+
return false;
2460+
}
2461+
24582462
$post_status = get_post_status_object( $post_status );
24592463

24602464
if ( ! $post_status ) {

0 commit comments

Comments
 (0)