Ticket #30946: 30946.diff
File 30946.diff, 2.4 KB (added by , 10 years ago) |
---|
-
src/wp-includes/comment.php
2205 2205 if ( empty( $comment ) ) { 2206 2206 return 0; 2207 2207 } 2208 2209 // Make sure that the comment post ID is valid (if specified). 2210 if ( isset( $commentarr['comment_post_ID'] ) && ! get_post( $commentarr['comment_post_ID'] ) ) { 2211 return 0; 2212 } 2213 2208 2214 // Escape data pulled from DB. 2209 2215 $comment = wp_slash($comment); 2210 2216 … … 2239 2245 2240 2246 $comment_ID = $data['comment_ID']; 2241 2247 $comment_post_ID = $data['comment_post_ID']; 2242 $keys = array( 'comment_ content', 'comment_author', 'comment_author_email', 'comment_approved', 'comment_karma', 'comment_author_url', 'comment_date', 'comment_date_gmt', 'comment_parent' );2248 $keys = array( 'comment_post_ID', 'comment_content', 'comment_author', 'comment_author_email', 'comment_approved', 'comment_karma', 'comment_author_url', 'comment_date', 'comment_date_gmt', 'comment_parent' ); 2243 2249 $data = wp_array_slice_assoc( $data, $keys ); 2244 2250 $rval = $wpdb->update( $wpdb->comments, $data, compact( 'comment_ID' ) ); 2245 2251 -
tests/phpunit/tests/comment.php
6 6 class Tests_Comment extends WP_UnitTestCase { 7 7 function test_wp_update_comment() { 8 8 $post = $this->factory->post->create_and_get( array( 'post_title' => 'some-post', 'post_type' => 'post' ) ); 9 $post2 = $this->factory->post->create_and_get( array( 'post_title' => 'some-post-2', 'post_type' => 'post' ) ); 9 10 $comments = $this->factory->comment->create_post_comments( $post->ID, 5 ); 10 11 $result = wp_update_comment( array( 'comment_ID' => $comments[0], 'comment_parent' => $comments[1] ) ); 11 12 $this->assertEquals( 1, $result ); … … 13 14 $this->assertEquals( $comments[1], $comment->comment_parent ); 14 15 $result = wp_update_comment( array( 'comment_ID' => $comments[0], 'comment_parent' => $comments[1] ) ); 15 16 $this->assertEquals( 0, $result ); 17 $result = wp_update_comment( array( 'comment_ID' => $comments[0], 'comment_post_ID' => $post2->ID ) ); 18 $comment = get_comment( $comments[0] ); 19 $this->assertEquals( $post2->ID, $comment->comment_post_ID ); 16 20 } 17 21 18 22 public function test_get_approved_comments() {