Make WordPress Core


Ignore:
Timestamp:
11/06/2025 10:22:52 PM (11 months ago)
Author:
westonruter
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/post.php

    r61110 r61171  
    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        }
    … …  
    24562456function 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
Note: See TracChangeset for help on using the changeset viewer.