diff --git src/wp-includes/comment.php src/wp-includes/comment.php
index ef4b553..0701119 100644
|
|
function wp_update_comment($commentarr) { |
2027 | 2027 | $data = wp_array_slice_assoc( $data, $keys ); |
2028 | 2028 | $rval = $wpdb->update( $wpdb->comments, $data, compact( 'comment_ID' ) ); |
2029 | 2029 | |
| 2030 | // If metadata is provided, store it. |
| 2031 | if ( isset( $commentarr['comment_meta'] ) && is_array( $commentarr['comment_meta'] ) ) { |
| 2032 | foreach ( $commentarr['comment_meta'] as $meta_key => $meta_value ) { |
| 2033 | update_comment_meta( $comment_ID, $meta_key, $meta_value ); |
| 2034 | } |
| 2035 | } |
| 2036 | |
2030 | 2037 | clean_comment_cache( $comment_ID ); |
2031 | 2038 | wp_update_comment_count( $comment_post_ID ); |
2032 | 2039 | /** |
diff --git tests/phpunit/tests/comment.php tests/phpunit/tests/comment.php
index c2fc51b..a362f5d 100644
|
|
class Tests_Comment extends WP_UnitTestCase { |
58 | 58 | $this->assertEquals( 'pingback', $comment->comment_type ); |
59 | 59 | } |
60 | 60 | |
| 61 | |
| 62 | /** |
| 63 | * @ticket 36784 |
| 64 | */ |
| 65 | function test_wp_update_comment_updates_comment_meta() { |
| 66 | $comment_id = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id ) ); |
| 67 | wp_update_comment( array( |
| 68 | 'comment_ID' => $comment_id, |
| 69 | 'comment_meta' => array( |
| 70 | 'food' => 'taco', |
| 71 | 'sauce' => 'fire', |
| 72 | ), |
| 73 | ) ); |
| 74 | $this->assertEquals( 'fire', get_comment_meta( $comment_id, 'sauce', true ) ); |
| 75 | } |
| 76 | |
| 77 | |
61 | 78 | /** |
62 | 79 | * @ticket 30307 |
63 | 80 | */ |