From cb9f80009fd5610586f55b7730d3dcec6d77fe3d Mon Sep 17 00:00:00 2001 From: Scott Taylor Date: Thu, 20 Aug 2015 02:44:39 +0000 Subject: [PATCH] Comments shouldn't have more than one `_wp_trash_meta_status` entry. When deleting `_wp_trash_meta_status`, also delete `_wp_trash_meta_time`. See #11200. git-svn-id: https://develop.svn.wordpress.org/trunk@33654 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/comment.php | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/wp-includes/comment.php b/src/wp-includes/comment.php index 88b7fbb65a..9841d58ae2 100644 --- a/src/wp-includes/comment.php +++ b/src/wp-includes/comment.php @@ -1857,8 +1857,10 @@ function wp_trash_comment($comment_id) { do_action( 'trash_comment', $comment_id ); if ( wp_set_comment_status($comment_id, 'trash') ) { - add_comment_meta($comment_id, '_wp_trash_meta_status', $comment->comment_approved); - add_comment_meta($comment_id, '_wp_trash_meta_time', time() ); + delete_comment_meta( $comment_id, '_wp_trash_meta_status' ); + delete_comment_meta( $comment_id, '_wp_trash_meta_time' ); + add_comment_meta( $comment_id, '_wp_trash_meta_status', $comment->comment_approved ); + add_comment_meta( $comment_id, '_wp_trash_meta_time', time() ); /** * Fires immediately after a comment is sent to Trash. @@ -1938,7 +1940,10 @@ function wp_spam_comment($comment_id) { do_action( 'spam_comment', $comment_id ); if ( wp_set_comment_status($comment_id, 'spam') ) { - add_comment_meta($comment_id, '_wp_trash_meta_status', $comment->comment_approved); + delete_comment_meta( $comment_id, '_wp_trash_meta_status' ); + delete_comment_meta( $comment_id, '_wp_trash_meta_time' ); + add_comment_meta( $comment_id, '_wp_trash_meta_status', $comment->comment_approved ); + add_comment_meta( $comment_id, '_wp_trash_meta_time', time() ); /** * Fires immediately after a comment is marked as Spam. * @@ -1979,7 +1984,8 @@ function wp_unspam_comment($comment_id) { $status = '0'; if ( wp_set_comment_status($comment_id, $status) ) { - delete_comment_meta($comment_id, '_wp_trash_meta_status'); + delete_comment_meta( $comment_id, '_wp_trash_meta_status' ); + delete_comment_meta( $comment_id, '_wp_trash_meta_time' ); /** * Fires immediately after a comment is unmarked as Spam. *