diff --git a/src/wp-includes/blocks.php b/src/wp-includes/blocks.php
index 9df70abaf4..d6f78a7d2d 100644
a
|
b
|
function unregister_block_type( $name ) { |
424 | 424 | function has_blocks( $post = null ) { |
425 | 425 | if ( ! is_string( $post ) ) { |
426 | 426 | $wp_post = get_post( $post ); |
| 427 | |
| 428 | if ( null === $wp_post ) { |
| 429 | _doing_it_wrong( |
| 430 | __FUNCTION__, |
| 431 | sprintf( |
| 432 | /* translators: %s: The $post variable. */ |
| 433 | __( '%s is not a valid post.'), |
| 434 | '<code>$post</code>' |
| 435 | ), |
| 436 | '6.1.0' |
| 437 | ); |
| 438 | |
| 439 | return false; |
| 440 | } |
| 441 | |
427 | 442 | if ( $wp_post instanceof WP_Post ) { |
428 | 443 | $post = $wp_post->post_content; |
429 | 444 | } |
diff --git a/tests/phpunit/tests/blocks/register.php b/tests/phpunit/tests/blocks/register.php
index 408927197a..8c5b17493c 100644
a
|
b
|
class Tests_Blocks_Register extends WP_UnitTestCase { |
551 | 551 | $this->assertFalse( has_blocks( $content ) ); |
552 | 552 | } |
553 | 553 | |
| 554 | /** |
| 555 | * @ticket 55705 |
| 556 | * |
| 557 | * @expectedIncorrectUsage has_blocks |
| 558 | * |
| 559 | * @covers ::has_blocks |
| 560 | */ |
| 561 | public function test_has_blocks_with_invalid_post() { |
| 562 | $a_post = (object) array( 'ID' => 13585, 'filter' => 'display' ); |
| 563 | $this->assertFalse( has_blocks( $a_post ) ); |
| 564 | } |
| 565 | |
554 | 566 | /** |
555 | 567 | * @ticket 49615 |
556 | 568 | */ |