Make WordPress Core


Ignore:
Timestamp:
08/08/2022 08:20:43 AM (23 months ago)
Author:
audrasjb
Message:

Editor: Safeguard has_blocks() against fatal errors.

This changeset ensures has_blocks() doesn't return a fatal error when $post is not a valid post. If the post can't be retrieved, the function now returns false.

Props Howdy_McGee, costdev, colonelphantom, audrasjb, dlh, peterwilsoncc.
Fixes #55705.

File:
1 edited

Legend:

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

    r53799 r53858  
    426426    if ( ! is_string( $post ) ) {
    427427        $wp_post = get_post( $post );
    428         if ( $wp_post instanceof WP_Post ) {
    429             $post = $wp_post->post_content;
    430         }
     428
     429        if ( ! $wp_post instanceof WP_Post ) {
     430            return false;
     431        }
     432
     433        $post = $wp_post->post_content;
    431434    }
    432435
Note: See TracChangeset for help on using the changeset viewer.