From 8532edd5263dfefd353419a72e4d542748273c58 Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Sun, 1 Sep 2024 18:30:16 +0000 Subject: [PATCH] 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. Built from https://develop.svn.wordpress.org/trunk@58962 git-svn-id: http://core.svn.wordpress.org/trunk@58358 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/comment.php | 3 ++- wp-includes/meta.php | 3 ++- wp-includes/ms-site.php | 3 ++- wp-includes/post.php | 3 ++- wp-includes/taxonomy.php | 3 ++- wp-includes/user.php | 3 ++- wp-includes/version.php | 2 +- 7 files changed, 13 insertions(+), 7 deletions(-) diff --git a/wp-includes/comment.php b/wp-includes/comment.php index 748dd6161b..e4cc901df9 100644 --- a/wp-includes/comment.php +++ b/wp-includes/comment.php @@ -479,7 +479,8 @@ function delete_comment_meta( $comment_id, $meta_key, $meta_value = '' ) { * @return mixed An array of values if `$single` is false. * The value of meta data field if `$single` is true. * False for an invalid `$comment_id` (non-numeric, zero, or negative value). - * An empty string if a valid but non-existing comment ID is passed. + * An empty array if a valid but non-existing comment ID is passed and `$single` is false. + * An empty string if a valid but non-existing comment ID is passed and `$single` is true. */ function get_comment_meta( $comment_id, $key = '', $single = false ) { return get_metadata( 'comment', $comment_id, $key, $single ); diff --git a/wp-includes/meta.php b/wp-includes/meta.php index 96ace4e972..32838b135d 100644 --- a/wp-includes/meta.php +++ b/wp-includes/meta.php @@ -568,7 +568,8 @@ function delete_metadata( $meta_type, $object_id, $meta_key, $meta_value = '', $ * The value of the meta field if `$single` is true. * False for an invalid `$object_id` (non-numeric, zero, or negative value), * or if `$meta_type` is not specified. - * An empty string if a valid but non-existing object ID is passed. + * An empty array if a valid but non-existing object ID is passed and `$single` is false. + * An empty string if a valid but non-existing object ID is passed and `$single` is true. */ function get_metadata( $meta_type, $object_id, $meta_key = '', $single = false ) { $value = get_metadata_raw( $meta_type, $object_id, $meta_key, $single ); diff --git a/wp-includes/ms-site.php b/wp-includes/ms-site.php index 6e19758790..71d61cd6da 100644 --- a/wp-includes/ms-site.php +++ b/wp-includes/ms-site.php @@ -1069,7 +1069,8 @@ function delete_site_meta( $site_id, $meta_key, $meta_value = '' ) { * @return mixed An array of values if `$single` is false. * The value of meta data field if `$single` is true. * False for an invalid `$site_id` (non-numeric, zero, or negative value). - * An empty string if a valid but non-existing site ID is passed. + * An empty array if a valid but non-existing site ID is passed and `$single` is false. + * An empty string if a valid but non-existing site ID is passed and `$single` is true. */ function get_site_meta( $site_id, $key = '', $single = false ) { return get_metadata( 'blog', $site_id, $key, $single ); diff --git a/wp-includes/post.php b/wp-includes/post.php index 69f2afcb89..df4aa1c32f 100644 --- a/wp-includes/post.php +++ b/wp-includes/post.php @@ -2607,7 +2607,8 @@ function delete_post_meta( $post_id, $meta_key, $meta_value = '' ) { * @return mixed An array of values if `$single` is false. * The value of the meta field if `$single` is true. * False for an invalid `$post_id` (non-numeric, zero, or negative value). - * An empty string if a valid but non-existing post ID is passed. + * An empty array if a valid but non-existing post ID is passed and `$single` is false. + * An empty string if a valid but non-existing post ID is passed and `$single` is true. */ function get_post_meta( $post_id, $key = '', $single = false ) { return get_metadata( 'post', $post_id, $key, $single ); diff --git a/wp-includes/taxonomy.php b/wp-includes/taxonomy.php index 778a6a3947..bebf55ec79 100644 --- a/wp-includes/taxonomy.php +++ b/wp-includes/taxonomy.php @@ -1430,7 +1430,8 @@ function delete_term_meta( $term_id, $meta_key, $meta_value = '' ) { * @return mixed An array of values if `$single` is false. * The value of the meta field if `$single` is true. * False for an invalid `$term_id` (non-numeric, zero, or negative value). - * An empty string if a valid but non-existing term ID is passed. + * An empty array if a valid but non-existing term ID is passed and `$single` is false. + * An empty string if a valid but non-existing term ID is passed and `$single` is true. */ function get_term_meta( $term_id, $key = '', $single = false ) { return get_metadata( 'term', $term_id, $key, $single ); diff --git a/wp-includes/user.php b/wp-includes/user.php index 94468a5ff1..c234c495df 100644 --- a/wp-includes/user.php +++ b/wp-includes/user.php @@ -1185,7 +1185,8 @@ function delete_user_meta( $user_id, $meta_key, $meta_value = '' ) { * @return mixed An array of values if `$single` is false. * The value of meta data field if `$single` is true. * False for an invalid `$user_id` (non-numeric, zero, or negative value). - * An empty string if a valid but non-existing user ID is passed. + * An empty array if a valid but non-existing user ID is passed and `$single` is false. + * An empty string if a valid but non-existing user ID is passed and `$single` is true. */ function get_user_meta( $user_id, $key = '', $single = false ) { return get_metadata( 'user', $user_id, $key, $single ); diff --git a/wp-includes/version.php b/wp-includes/version.php index 46dfdbd7cf..664cb7e551 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -16,7 +16,7 @@ * * @global string $wp_version */ -$wp_version = '6.7-alpha-58961'; +$wp_version = '6.7-alpha-58962'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.