Skip to content

Commit 366a685

Browse files
committed
Ensure ID property exists before attempting to read it in get_post()
1 parent 417b389 commit 366a685

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

src/wp-includes/post.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1159,8 +1159,10 @@ function get_post( $post = null, $output = OBJECT, $filter = 'raw' ) {
11591159
$_post = new WP_Post( $_post );
11601160
} elseif ( 'raw' === $post->filter ) {
11611161
$_post = new WP_Post( $post );
1162-
} else {
1162+
} elseif ( isset( $post->ID ) ) {
11631163
$_post = WP_Post::get_instance( $post->ID );
1164+
} else {
1165+
$_post = null;
11641166
}
11651167
} else {
11661168
$_post = WP_Post::get_instance( $post );

0 commit comments

Comments
 (0)