From bf222a442b95e6eed6140553c89ce9a9bf01fc51 Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Tue, 30 Jun 2020 14:12:04 +0000 Subject: [PATCH] Comments: Make `wp_update_comment()` return `false` instead of 0 for an invalid comment or post ID. This addresses an inconsistency where 0 could mean one of the three scenarios: * Invalid comment ID. * Invalid comment post ID. * No DB rows updated. This is not an error and should not be treated as one. With this change, `wp_update_comment()` always returns either `false` or a `WP_Error` object on failure, depending on the value of the `$wp_error` parameter. Follow-up to [48154], [48215], [48216], [48218], [48230]. Props dd32, jnylen0, enrico.sorcinelli. Fixes #39732. See #38700, #39735. Built from https://develop.svn.wordpress.org/trunk@48235 git-svn-id: http://core.svn.wordpress.org/trunk@48004 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/comment.php | 6 ++++-- wp-includes/version.php | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/wp-includes/comment.php b/wp-includes/comment.php index 9868d62c23..22543a998a 100644 --- a/wp-includes/comment.php +++ b/wp-includes/comment.php @@ -2422,6 +2422,8 @@ function wp_set_comment_status( $comment_id, $comment_status, $wp_error = false * @since 2.0.0 * @since 4.9.0 Add updating comment meta during comment update. * @since 5.5.0 The `$wp_error` parameter was added. + * @since 5.5.0 The return values for an invalid comment or post ID + * were changed to false instead of 0. * * @global wpdb $wpdb WordPress database abstraction object. * @@ -2439,7 +2441,7 @@ function wp_update_comment( $commentarr, $wp_error = false ) { if ( $wp_error ) { return new WP_Error( 'invalid_comment_id', __( 'Invalid comment ID.' ) ); } else { - return 0; + return false; } } @@ -2448,7 +2450,7 @@ function wp_update_comment( $commentarr, $wp_error = false ) { if ( $wp_error ) { return new WP_Error( 'invalid_post_id', __( 'Invalid post ID.' ) ); } else { - return 0; + return false; } } diff --git a/wp-includes/version.php b/wp-includes/version.php index 460d3d9988..404aa7c2b0 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -13,7 +13,7 @@ * * @global string $wp_version */ -$wp_version = '5.5-alpha-48234'; +$wp_version = '5.5-alpha-48235'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.