Comments: Allow wp_update_comment() to return WP_Error().

The `wp_update_comment_data` filter introduced in 4.7 allows comment data to be filtered before it is updated in the database.

The patch aims to handle `WP_Error` as the filter above return value in a similar manner as is done for `wp_new_comment()`.


Fixes #39732.

Props: enricosorcinelli, swissspidy, gkloveweb, jnylen0, jbpaul17, afercia, SergeyBiryukov, audrasjb, imath, davidbaumwald.


git-svn-id: https://develop.svn.wordpress.org/trunk@48154 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Jake Spurlock
2020-06-24 00:03:33 +00:00
parent 7a8d8a3e8a
commit ec062c08fe
9 changed files with 135 additions and 13 deletions
+4 -1
View File
@@ -339,7 +339,10 @@ switch ( $action ) {
check_admin_referer( 'update-comment_' . $comment_id );
edit_comment();
$updated = edit_comment();
if ( is_wp_error( $updated ) ) {
wp_die( $updated->get_error_message() );
}
$location = ( empty( $_POST['referredby'] ) ? "edit-comments.php?p=$comment_post_id" : $_POST['referredby'] ) . '#comment-' . $comment_id;
+5 -1
View File
@@ -1410,7 +1410,11 @@ function wp_ajax_edit_comment() {
if ( isset( $_POST['status'] ) ) {
$_POST['comment_status'] = $_POST['status'];
}
edit_comment();
$updated = edit_comment();
if ( is_wp_error( $updated ) ) {
wp_die( $updated->get_error_message() );
}
$position = ( isset( $_POST['position'] ) && (int) $_POST['position'] ) ? (int) $_POST['position'] : '-1';
$checkbox = ( isset( $_POST['checkbox'] ) && true == $_POST['checkbox'] ) ? 1 : 0;
+1 -1
View File
@@ -92,7 +92,7 @@ function edit_comment() {
$_POST['comment_date'] = "$aa-$mm-$jj $hh:$mn:$ss";
}
wp_update_comment( $_POST );
return wp_update_comment( $_POST, true );
}
/**