Make WordPress Core


Ignore:
Timestamp:
08/08/2022 08:20:43 AM (2 years 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/tests/phpunit/tests/blocks/register.php

    r53718 r53858  
    554554
    555555    /**
     556     * Tests that `has_blocks()` returns `false` with an invalid post.
     557     *
     558     * @ticket 55705
     559     *
     560     * @covers ::has_blocks
     561     */
     562    public function test_has_blocks_with_invalid_post() {
     563        $a_post = (object) array(
     564            'ID'     => 55705,
     565            'filter' => 'display',
     566        );
     567        $this->assertFalse( has_blocks( $a_post ) );
     568    }
     569
     570    /**
    556571     * @ticket 49615
    557572     */
Note: See TracChangeset for help on using the changeset viewer.