[wp-trac] [WordPress Trac] #60646: Docs: Incorrect return type specified for get_post_custom with negative post ID value

WordPress Trac noreply at wordpress.org
Tue Feb 27 15:11:58 UTC 2024


#60646: Docs: Incorrect return type specified for get_post_custom with negative
post ID value
-------------------------------+-----------------------------
 Reporter:  roytanck           |      Owner:  (none)
     Type:  defect (bug)       |     Status:  new
 Priority:  normal             |  Milestone:  Awaiting Review
Component:  Posts, Post Types  |    Version:
 Severity:  trivial            |   Keywords:
  Focuses:  docs               |
-------------------------------+-----------------------------
 On the documentation page for `get_post_custom`, the return type section
 says:

 "False for an invalid $post_id (non-numeric, zero, or negative value)."

 https://developer.wordpress.org/reference/functions/get_post_custom/

 However, the function applies `absint` to the `$post_id`. So if its value
 would be negative (i.e. -10), this would be converted a positive value
 (10), and `get_post_meta` would be called for that post. This post ID can
 then either exists (resulting in an array being returned) or not (empty
 string).

 Perhaps a negative numerical value should not converted? There's a
 potential for mix-ups? If we keep the code as is, the docs should probably
 specify that negative values are converted to positive.

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


More information about the wp-trac mailing list