[wp-trac] [WordPress Trac] #45329: get_post_permalink tries is_wp_error on get_post which it will never be

WordPress Trac noreply at wordpress.org
Mon Nov 12 11:11:09 UTC 2018


#45329: get_post_permalink tries is_wp_error on get_post which it will never be
--------------------------+-----------------------------
 Reporter:  renegeuze     |      Owner:  (none)
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  General       |    Version:
 Severity:  normal        |   Keywords:
  Focuses:                |
--------------------------+-----------------------------
 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)

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/45329>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list