Skip to content

Commit ab523eb

Browse files
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. git-svn-id: https://develop.svn.wordpress.org/trunk@58962 602fd350-edb4-49c9-b593-d223f7449a82
1 parent ac9dc92 commit ab523eb

File tree

6 files changed

+12
-6
lines changed

6 files changed

+12
-6
lines changed

src/wp-includes/comment.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -479,7 +479,8 @@ function delete_comment_meta( $comment_id, $meta_key, $meta_value = '' ) {
479479
* @return mixed An array of values if `$single` is false.
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
*/
484485
function get_comment_meta( $comment_id, $key = '', $single = false ) {
485486
return get_metadata( 'comment', $comment_id, $key, $single );

src/wp-includes/meta.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -568,7 +568,8 @@ function delete_metadata( $meta_type, $object_id, $meta_key, $meta_value = '', $
568568
* The value of the meta field if `$single` is true.
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
*/
573574
function get_metadata( $meta_type, $object_id, $meta_key = '', $single = false ) {
574575
$value = get_metadata_raw( $meta_type, $object_id, $meta_key, $single );

src/wp-includes/ms-site.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1069,7 +1069,8 @@ function delete_site_meta( $site_id, $meta_key, $meta_value = '' ) {
10691069
* @return mixed An array of values if `$single` is false.
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
*/
10741075
function get_site_meta( $site_id, $key = '', $single = false ) {
10751076
return get_metadata( 'blog', $site_id, $key, $single );

src/wp-includes/post.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2607,7 +2607,8 @@ function delete_post_meta( $post_id, $meta_key, $meta_value = '' ) {
26072607
* @return mixed An array of values if `$single` is false.
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
*/
26122613
function get_post_meta( $post_id, $key = '', $single = false ) {
26132614
return get_metadata( 'post', $post_id, $key, $single );

src/wp-includes/taxonomy.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1430,7 +1430,8 @@ function delete_term_meta( $term_id, $meta_key, $meta_value = '' ) {
14301430
* @return mixed An array of values if `$single` is false.
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
*/
14351436
function get_term_meta( $term_id, $key = '', $single = false ) {
14361437
return get_metadata( 'term', $term_id, $key, $single );

src/wp-includes/user.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1185,7 +1185,8 @@ function delete_user_meta( $user_id, $meta_key, $meta_value = '' ) {
11851185
* @return mixed An array of values if `$single` is false.
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
*/
11901191
function get_user_meta( $user_id, $key = '', $single = false ) {
11911192
return get_metadata( 'user', $user_id, $key, $single );

0 commit comments

Comments
 (0)