From a744bb9a5f8a78e289c9a6764d6c24247c8d5779 Mon Sep 17 00:00:00 2001 From: Sergey Biryukov <sergeybiryukov@git.wordpress.org> Date: Tue, 13 Jan 2015 06:41:19 +0000 Subject: [PATCH] Add 'comment_type' to the list of fields wp_update_comment() can update. props desaiuditd. fixes #30627. git-svn-id: https://develop.svn.wordpress.org/trunk@31171 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/comment.php | 2 +- tests/phpunit/tests/comment.php | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/wp-includes/comment.php b/src/wp-includes/comment.php index d671597ed5..b30df85eda 100644 --- a/src/wp-includes/comment.php +++ b/src/wp-includes/comment.php @@ -2239,7 +2239,7 @@ function wp_update_comment($commentarr) { $comment_ID = $data['comment_ID']; $comment_post_ID = $data['comment_post_ID']; - $keys = array( 'comment_content', 'comment_author', 'comment_author_email', 'comment_approved', 'comment_karma', 'comment_author_url', 'comment_date', 'comment_date_gmt', 'comment_parent' ); + $keys = array( 'comment_content', 'comment_author', 'comment_author_email', 'comment_approved', 'comment_karma', 'comment_author_url', 'comment_date', 'comment_date_gmt', 'comment_type', 'comment_parent' ); $data = wp_array_slice_assoc( $data, $keys ); $rval = $wpdb->update( $wpdb->comments, $data, compact( 'comment_ID' ) ); diff --git a/tests/phpunit/tests/comment.php b/tests/phpunit/tests/comment.php index 6271696201..7514f90df3 100644 --- a/tests/phpunit/tests/comment.php +++ b/tests/phpunit/tests/comment.php @@ -15,6 +15,19 @@ class Tests_Comment extends WP_UnitTestCase { $this->assertEquals( 0, $result ); } + /** + * @ticket 30627 + */ + function test_wp_update_comment_updates_comment_type() { + $post_id = $this->factory->post->create(); + $comment_id = $this->factory->comment->create( array( 'comment_post_ID' => $post_id ) ); + + wp_update_comment( array( 'comment_ID' => $comment_id, 'comment_type' => 'pingback' ) ); + + $comment = get_comment( $comment_id ); + $this->assertEquals( 'pingback', $comment->comment_type ); + } + public function test_get_approved_comments() { $p = $this->factory->post->create(); $ca1 = $this->factory->comment->create( array( 'comment_post_ID' => $p, 'comment_approved' => '1' ) );