diff --git a/src/wp-includes/post.php b/src/wp-includes/post.php
index 3ec68625a5..be09797cd8 100644
a
|
b
|
function _publish_post_hook( $post_id ) { |
7436 | 7436 | * |
7437 | 7437 | * @since 3.1.0 |
7438 | 7438 | * |
7439 | | * @param int|WP_Post $post Post ID or post object. |
| 7439 | * @param int|WP_Post|null $post Optional. Post ID or post object. |
7440 | 7440 | * @return int|false Post parent ID (which can be 0 if there is no parent), |
7441 | 7441 | * or false if the post does not exist. |
7442 | 7442 | */ |
7443 | | function wp_get_post_parent_id( $post ) { |
| 7443 | function wp_get_post_parent_id( $post = null ) { |
7444 | 7444 | $post = get_post( $post ); |
7445 | 7445 | if ( ! $post || is_wp_error( $post ) ) { |
7446 | 7446 | return false; |
diff --git a/tests/phpunit/tests/post/wpGetPostParentId.php b/tests/phpunit/tests/post/wpGetPostParentId.php
index bd25232830..b756c7eb90 100644
a
|
b
|
class Tests_Post_wpGetPostParentId extends WP_UnitTestCase { |
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 | */ |
| 39 | public function test_wp_get_post_parent_id_with_no_post_argument_default_to_global_post_id() { |
| 40 | $GLOBALS['post'] = get_post( self::$post_id ); |
| 41 | $this->assertSame( self::$parent_post_id, wp_get_post_parent_id() ); |
| 42 | } |
| 43 | |
36 | 44 | public function test_wp_get_post_parent_id_with_non_existing_id_default_to_global_post_id() { |
37 | 45 | $GLOBALS['post'] = get_post( self::$post_id ); |
38 | 46 | $this->assertSame( self::$parent_post_id, wp_get_post_parent_id( 0 ) ); |