[wp-trac] [WordPress Trac] #51797: Clarify return results for a non-existing ID in metadata functions

WordPress Trac noreply at wordpress.org
Tue Nov 17 13:44:26 UTC 2020


#51797: Clarify return results for a non-existing ID in metadata functions
--------------------------------+--------------------
 Reporter:  SergeyBiryukov      |      Owner:  (none)
     Type:  defect (bug)        |     Status:  new
 Priority:  normal              |  Milestone:  5.7
Component:  Options, Meta APIs  |    Version:  5.5
 Severity:  normal              |   Keywords:
  Focuses:  docs                |
--------------------------------+--------------------
 Background: #40519

 [48658] documented that various metadata functions return `false` for an
 invalid ID. However, that does not clarify what an invalid ID is: a non-
 numeric, zero, or negative value.

 For example, if a valid but non-existing post ID is passed,
 `get_post_meta()` returns an empty string, not `false`, but it's not
 mentioned in the documentation.

 This applies to:
 * `get_comment_meta()`
 * `get_site_meta()`
 * `get_post_meta()`
 * `get_term_meta()`
 * `get_user_meta()`

 And potentially these functions too:
 * `get_metadata()`
 * `get_metadata_raw()`
 * `get_metadata_default()`

 Props to @icopydoc for the [https://ru.wordpress.org/support/topic
 /get_post_meta-несуществуюего-поста-медиафайла/ report on support forums].

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


More information about the wp-trac mailing list