Make WordPress Core

Changeset 58962


Ignore:
Timestamp:
09/01/2024 06:28:22 PM (12 days ago)
Author:
SergeyBiryukov
Message:

Docs: Further clarify return results for a non-existing ID in metadata functions.

This adds a note that the functions return either an empty array or an empty string for a valid but non-existing ID, depending on the $single parameter.

Follow-up to [48658], [50641].

Props rodrigosprimo, jrf.
See #61608.

Location:
trunk/src/wp-includes
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/comment.php

    r58401 r58962  
    480480 *               The value of meta data field if `$single` is true.
    481481 *               False for an invalid `$comment_id` (non-numeric, zero, or negative value).
    482  *               An empty string if a valid but non-existing comment ID is passed.
     482 *               An empty array if a valid but non-existing comment ID is passed and `$single` is false.
     483 *               An empty string if a valid but non-existing comment ID is passed and `$single` is true.
    483484 */
    484485function get_comment_meta( $comment_id, $key = '', $single = false ) {
  • trunk/src/wp-includes/meta.php

    r56714 r58962  
    569569 *               False for an invalid `$object_id` (non-numeric, zero, or negative value),
    570570 *               or if `$meta_type` is not specified.
    571  *               An empty string if a valid but non-existing object ID is passed.
     571 *               An empty array if a valid but non-existing object ID is passed and `$single` is false.
     572 *               An empty string if a valid but non-existing object ID is passed and `$single` is true.
    572573 */
    573574function get_metadata( $meta_type, $object_id, $meta_key = '', $single = false ) {
  • trunk/src/wp-includes/ms-site.php

    r58097 r58962  
    10701070 *               The value of meta data field if `$single` is true.
    10711071 *               False for an invalid `$site_id` (non-numeric, zero, or negative value).
    1072  *               An empty string if a valid but non-existing site ID is passed.
     1072 *               An empty array if a valid but non-existing site ID is passed and `$single` is false.
     1073 *               An empty string if a valid but non-existing site ID is passed and `$single` is true.
    10731074 */
    10741075function get_site_meta( $site_id, $key = '', $single = false ) {
  • trunk/src/wp-includes/post.php

    r58849 r58962  
    26082608 *               The value of the meta field if `$single` is true.
    26092609 *               False for an invalid `$post_id` (non-numeric, zero, or negative value).
    2610  *               An empty string if a valid but non-existing post ID is passed.
     2610 *               An empty array if a valid but non-existing post ID is passed and `$single` is false.
     2611 *               An empty string if a valid but non-existing post ID is passed and `$single` is true.
    26112612 */
    26122613function get_post_meta( $post_id, $key = '', $single = false ) {
  • trunk/src/wp-includes/taxonomy.php

    r58427 r58962  
    14311431 *               The value of the meta field if `$single` is true.
    14321432 *               False for an invalid `$term_id` (non-numeric, zero, or negative value).
    1433  *               An empty string if a valid but non-existing term ID is passed.
     1433 *               An empty array if a valid but non-existing term ID is passed and `$single` is false.
     1434 *               An empty string if a valid but non-existing term ID is passed and `$single` is true.
    14341435 */
    14351436function get_term_meta( $term_id, $key = '', $single = false ) {
  • trunk/src/wp-includes/user.php

    r58955 r58962  
    11861186 *               The value of meta data field if `$single` is true.
    11871187 *               False for an invalid `$user_id` (non-numeric, zero, or negative value).
    1188  *               An empty string if a valid but non-existing user ID is passed.
     1188 *               An empty array if a valid but non-existing user ID is passed and `$single` is false.
     1189 *               An empty string if a valid but non-existing user ID is passed and `$single` is true.
    11891190 */
    11901191function get_user_meta( $user_id, $key = '', $single = false ) {
Note: See TracChangeset for help on using the changeset viewer.