WordPress.org

Make WordPress Core

Opened 4 years ago

Closed 11 months ago

Last modified 11 months ago

#40519 closed enhancement (fixed)

Document that get_metadata() returns false for bad parameters

Reported by: salcode Owned by:
Milestone: 5.5 Priority: normal
Severity: normal Version: 4.8
Component: Options, Meta APIs Keywords: has-patch needs-refresh
Focuses: docs Cc:

Description

Currently the inline documentation for the return value for get_metadata() reads

@return mixed Single metadata value, or array of values

I've noticed that if you pass in a post id of zero, you get a value of false. While the value of false falls under the category of "mixed", I would like to see it mentioned explicitly.

If we make this change, we should do the same for any function that uses get_metadata(), e.g. get_post_meta()

Attachments (1)

40519.diff (4.2 KB) - added by salcode 4 years ago.

Download all attachments as: .zip

Change History (6)

@salcode
4 years ago

#1 @salcode
4 years ago

  • Keywords has-patch added

Here is the [GitHub branch](https://github.com/salcode/wordpress-develop/tree/sf/get-metadata-doc-40519) where I've made this change.

This ticket was mentioned in Slack in #core by noisysocks. View the logs.


11 months ago

#3 @mikeschroder
11 months ago

  • Component changed from General to Options, Meta APIs
  • Keywords needs-refresh added
  • Milestone changed from Awaiting Review to Future Release

Hi @salcode!

Apologies for the very slow reply on this, and thanks much for your work and patch.

We chatted about this ticket in today's ticket triage.

It looks like these changes would still help make the documentation clearer, but unfortunately the patch doesn't apply anymore.

If you, or anyone else, has a chance to refresh the patch, it would be much appreciated.

#4 @johnbillion
11 months ago

  • Milestone changed from Future Release to 5.5
  • Resolution set to fixed
  • Status changed from new to closed

This was fixed in [48192] and [48411].

#5 @SergeyBiryukov
11 months ago

In 48658:

Docs: Document that various metadata functions return false for an invalid ID.

Props salcode.
See #40519.

Note: See TracTickets for help on using tickets.