Opened 18 years ago
Closed 18 years ago
#6953 closed defect (bug) (fixed)
get_post() returns bogus object for non-existing post IDs
| Reported by: |
|
Owned by: |
|
|---|---|---|---|
| Milestone: | 2.6 | Priority: | normal |
| Severity: | normal | Version: | 2.5.1 |
| Component: | General | Keywords: | get_post has-patch tested |
| Focuses: | Cc: |
Description
It should return null or false instead.
var_dump( get_post( $dummy_id = -999 ));
returns
object(stdClass)(1) {
["ancestors"]=>
array(0) {
}
}
The object converts to boolean true, which can confuse things.
_get_post_ancestors($_post) is being called without checking that the previous query actually returned a post (in wp-includes/post.php).
Attachments (1)
Change History (6)
Note: See
TracTickets for help on using
tickets.
get_post() returns &$null immediately for non-existing post IDs