diff --git a/src/wp-includes/post.php b/src/wp-includes/post.php
index 286ad8ccf61..5a0671ac463 100644
a
|
b
|
function _publish_post_hook( $post_id ) { |
7642 | 7642 | * Returns the ID of the post's parent. |
7643 | 7643 | * |
7644 | 7644 | * @since 3.1.0 |
| 7645 | * @since 5.9.0 The `$post` parameter was made optional. |
7645 | 7646 | * |
7646 | | * @param int|WP_Post $post Post ID or post object. |
| 7647 | * @param int|WP_Post|null $post Optional. Post ID or post object. Defaults to global $post. |
7647 | 7648 | * @return int|false Post parent ID (which can be 0 if there is no parent), |
7648 | 7649 | * or false if the post does not exist. |
7649 | 7650 | */ |
7650 | | function wp_get_post_parent_id( $post ) { |
| 7651 | function wp_get_post_parent_id( $post = null ) { |
7651 | 7652 | $post = get_post( $post ); |
7652 | 7653 | if ( ! $post || is_wp_error( $post ) ) { |
7653 | 7654 | return false; |
diff --git a/tests/phpunit/tests/post/wpGetPostParentId.php b/tests/phpunit/tests/post/wpGetPostParentId.php
index bd25232830b..b2a054239d2 100644
a
|
b
|
public function test_wp_get_post_parent_id_with_post_id() { |
33 | 33 | $this->assertSame( self::$parent_post_id, wp_get_post_parent_id( self::$post_id ) ); |
34 | 34 | } |
35 | 35 | |
| 36 | /* |
| 37 | * @ticket 48358 |
| 38 | * @covers ::wp_get_post_parent_id |
| 39 | */ |
| 40 | public function test_wp_get_post_parent_id_with_no_post_argument_default_to_global_post_id() { |
| 41 | $GLOBALS['post'] = get_post( self::$post_id ); |
| 42 | $this->assertSame( self::$parent_post_id, wp_get_post_parent_id() ); |
| 43 | } |
| 44 | |
36 | 45 | public function test_wp_get_post_parent_id_with_non_existing_id_default_to_global_post_id() { |
37 | 46 | $GLOBALS['post'] = get_post( self::$post_id ); |
38 | 47 | $this->assertSame( self::$parent_post_id, wp_get_post_parent_id( 0 ) ); |