#45329 closed defect (bug) (fixed)
get_post_permalink tries is_wp_error on get_post which it will never be
Reported by: | renegeuze | Owned by: | SergeyBiryukov |
---|---|---|---|
Milestone: | 6.1 | Priority: | normal |
Severity: | normal | Version: | |
Component: | Posts, Post Types | Keywords: | needs-dev-note |
Focuses: | Cc: |
Description
get_post_permalink incorrectly calls is_wp_error
on the result of get_post($id)
. Instead it should check for !($post instanceof \WP_Post)
or just $post === false
, since at this location it won't ever be an array either.
Documentation is wrong too - but I assume that's generated from docBlock.
To reproduce: get_post_permalink('whatever-argument-that-does-not-resolve-an-existing-post');
Expected result: return false(or an actual WP_Error but other code like get_permalink()
does not expect it)
Attachments (1)
Change History (8)
#1
@
6 years ago
- Component changed from General to Posts, Post Types
- Keywords needs-patch needs-unit-tests added
#3
@
2 years ago
- Owner set to SergeyBiryukov
- Resolution set to fixed
- Status changed from new to closed
In 53733:
#6
@
2 years ago
- Keywords needs-dev-note added
A call out for this on the other developer focused changed dev-note would be helpful.
This ticket was mentioned in Slack in #core by sergey. View the logs.
2 years ago
Note: See
TracTickets for help on using
tickets.
Hi there, welcome to WordPress Trac!
Thanks for the ticket, sorry it took so long for someone to get back to you.
Found this while working on #56243, still appears to be a valid issue.