[wp-trac] [WordPress Trac] #48358: wp_get_post_parent_id() does not default to global $post

WordPress Trac noreply at wordpress.org
Thu Oct 17 15:22:23 UTC 2019


#48358: wp_get_post_parent_id() does not default to global $post
-------------------------------+-----------------------------
 Reporter:  danielpost         |      Owner:  (none)
     Type:  defect (bug)       |     Status:  new
 Priority:  normal             |  Milestone:  Awaiting Review
Component:  Posts, Post Types  |    Version:  5.2.3
 Severity:  normal             |   Keywords:
  Focuses:                     |
-------------------------------+-----------------------------
 https://core.trac.wordpress.org/browser/tags/5.2.4/src/wp-
 includes/post.php#L6595

 Because `wp_get_post_parent_id()` does not declare a default value for the
 `$post` parameter, calling it without explicitly passing the `$post`
 parameter results in an error. This means that it will never default to
 the global `$post`. I believe the fix here is to declare `$post = null` in
 the function declaration and specify in the PHPDoc that this parameter is
 optional, similar to how other functions handle this.

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


More information about the wp-trac mailing list