WordPress.org

Make WordPress Core

Opened 11 months ago

Last modified 11 months ago

#45329 new defect (bug)

get_post_permalink tries is_wp_error on get_post which it will never be

Reported by: renegeuze Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version:
Component: Posts, Post Types Keywords: needs-patch needs-unit-tests
Focuses: Cc:
PR Number:

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)

45329.diff (897 bytes) - added by manzoorwani.jk 7 months ago.

Download all attachments as: .zip

Change History (2)

#1 @SergeyBiryukov
11 months ago

  • Component changed from General to Posts, Post Types
  • Keywords needs-patch needs-unit-tests added
Note: See TracTickets for help on using tickets.