Ticket #36784: 36784.5.diff
File 36784.5.diff, 2.0 KB (added by , 8 years ago) |
---|
-
src/wp-includes/comment.php
2126 2126 * Filters the comment and makes sure certain fields are valid before updating. 2127 2127 * 2128 2128 * @since 2.0.0 2129 * @since 4.9.0 Add updating comment meta during comment update. 2129 2130 * 2130 2131 * @global wpdb $wpdb WordPress database abstraction object. 2131 2132 * … … 2199 2200 2200 2201 $rval = $wpdb->update( $wpdb->comments, $data, compact( 'comment_ID' ) ); 2201 2202 2203 // If metadata is provided, store it. 2204 if ( isset( $commentarr['comment_meta'] ) && is_array( $commentarr['comment_meta'] ) ) { 2205 foreach ( $commentarr['comment_meta'] as $meta_key => $meta_value ) { 2206 update_comment_meta( $comment_ID, $meta_key, $meta_value ); 2207 } 2208 } 2209 2202 2210 clean_comment_cache( $comment_ID ); 2203 2211 wp_update_comment_count( $comment_post_ID ); 2204 2212 /** … … 3005 3013 * @param int $comment_post_ID Post ID. 3006 3014 */ 3007 3015 do_action( 'comment_on_draft', $comment_post_ID ); 3008 3016 3009 3017 if ( current_user_can( 'read_post', $comment_post_ID ) ) { 3010 3018 return new WP_Error( 'comment_on_draft', __( 'Sorry, comments are not allowed for this item.' ), 403 ); 3011 3019 } else { -
tests/phpunit/tests/comment.php
52 52 $this->assertEquals( 'pingback', $comment->comment_type ); 53 53 } 54 54 55 56 /** 57 * @ticket 36784 58 */ 59 function test_wp_update_comment_updates_comment_meta() { 60 $comment_id = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id ) ); 61 wp_update_comment( array( 62 'comment_ID' => $comment_id, 63 'comment_meta' => array( 64 'food' => 'taco', 65 'sauce' => 'fire', 66 ), 67 ) ); 68 $this->assertEquals( 'fire', get_comment_meta( $comment_id, 'sauce', true ) ); 69 } 70 71 55 72 /** 56 73 * @ticket 30307 57 74 */