Opened 4 years ago
Closed 4 years ago
#51797 closed defect (bug) (fixed)
Clarify return results for a non-existing ID in metadata functions
Reported by: | SergeyBiryukov | Owned by: | davidbaumwald |
---|---|---|---|
Milestone: | 5.8 | Priority: | normal |
Severity: | normal | Version: | 5.5 |
Component: | Options, Meta APIs | Keywords: | has-patch commit |
Focuses: | docs | Cc: |
Description
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 report on support forums.
Attachments (4)
Change History (10)
This ticket was mentioned in Slack in #core by metalandcoffee. View the logs.
4 years ago
#2
@
4 years ago
- Keywords has-patch added
Thanks @davidkryzaniak. In 51797.2.diff I completed the docs with more details and I also updated get_metadata()
and get_metadata_raw()
. I didn't change get_metadata_default()
because I'm not sure this comment for the returned value is relevant for this function.
#3
@
4 years ago
- Milestone changed from 5.7 to 5.8
Thanks for the patch!
Looks like this needs some minor adjustments to replace "post ID" with "term ID", "user ID", etc. where appropriate. Moving to the next release for now for a closer review.
#5
@
4 years ago
- Keywords commit added
Thanks for the patch! This mostly looks good.
51797.4.diff makes some further adjustments for consistency and accuracy.
Updates to docs