Ticket #30307: 30307.3.patch
File 30307.3.patch, 3.2 KB (added by , 10 years ago) |
---|
-
src/wp-admin/includes/comment.php
37 37 if ( ! current_user_can( 'edit_comment', (int) $_POST['comment_ID'] ) ) 38 38 wp_die ( __( 'You are not allowed to edit comments on this post.' ) ); 39 39 40 $comment_data = array(); 41 40 42 if ( isset( $_POST['newcomment_author'] ) ) 41 $ _POST['comment_author'] = $_POST['newcomment_author'];43 $comment_data['comment_author'] = $_POST['newcomment_author']; 42 44 if ( isset( $_POST['newcomment_author_email'] ) ) 43 $ _POST['comment_author_email'] = $_POST['newcomment_author_email'];45 $comment_data['comment_author_email'] = $_POST['newcomment_author_email']; 44 46 if ( isset( $_POST['newcomment_author_url'] ) ) 45 $ _POST['comment_author_url'] = $_POST['newcomment_author_url'];47 $comment_data['comment_author_url'] = $_POST['newcomment_author_url']; 46 48 if ( isset( $_POST['comment_status'] ) ) 47 $ _POST['comment_approved'] = $_POST['comment_status'];49 $comment_data['comment_approved'] = $_POST['comment_status']; 48 50 if ( isset( $_POST['content'] ) ) 49 $ _POST['comment_content'] = $_POST['content'];51 $comment_data['comment_content'] = $_POST['content']; 50 52 if ( isset( $_POST['comment_ID'] ) ) 51 $ _POST['comment_ID'] = (int) $_POST['comment_ID'];53 $comment_data['comment_ID'] = (int) $_POST['comment_ID']; 52 54 53 foreach ( array ('aa', 'mm', 'jj', 'hh', 'mn') as $timeunit ) {54 if ( ! empty( $_POST['hidden_' . $timeunit] ) && $_POST['hidden_' . $timeunit] != $_POST[$timeunit] ) {55 $ _POST['edit_date'] = '1';55 foreach ( array( 'aa', 'mm', 'jj', 'hh', 'mn' ) as $timeunit ) { 56 if ( ! empty( $_POST['hidden_' . $timeunit] ) && $_POST['hidden_' . $timeunit] != $_POST[$timeunit] ) { 57 $comment_data['edit_date'] = '1'; 56 58 break; 57 59 } 58 60 } 59 61 60 if ( ! empty ( $_POST['edit_date'] ) ) {62 if ( ! empty( $comment_data['edit_date'] ) ) { 61 63 $aa = $_POST['aa']; 62 64 $mm = $_POST['mm']; 63 65 $jj = $_POST['jj']; … … 68 70 $hh = ($hh > 23 ) ? $hh -24 : $hh; 69 71 $mn = ($mn > 59 ) ? $mn -60 : $mn; 70 72 $ss = ($ss > 59 ) ? $ss -60 : $ss; 71 $ _POST['comment_date'] = "$aa-$mm-$jj $hh:$mn:$ss";73 $comment_data['comment_date'] = "$aa-$mm-$jj $hh:$mn:$ss"; 72 74 } 73 75 74 wp_update_comment( $ _POST);76 wp_update_comment( $comment_data ); 75 77 } 76 78 77 79 /** -
tests/phpunit/tests/comment.php
36 36 * @ticket 30307 37 37 */ 38 38 function test_wp_update_comment_updates_user_id() { 39 wp_set_current_user( 1 ); 39 40 $post_id = $this->factory->post->create(); 40 $comment_id = $this->factory->comment->create( array( 'comment_post_ID' => $post_id ) );41 $comment_id = $this->factory->comment->create( array( 'comment_post_ID' => $post_id, 'user_id' => 1 ) ); 41 42 42 wp_update_comment( array( 'comment_ID' => $comment_id, 'user_id' => 1) );43 wp_update_comment( array( 'comment_ID' => $comment_id, 'user_id' => 0 ) ); 43 44 44 45 $comment = get_comment( $comment_id ); 45 $this->assertEquals( 1, $comment->user_id );46 $this->assertEquals( 0, $comment->user_id ); 46 47 } 47 48 48 49 public function test_get_approved_comments() {