Ticket #27471: 27471.2.diff
File 27471.2.diff, 2.3 KB (added by , 9 years ago) |
---|
-
src/wp-includes/class-wp-xmlrpc-server.php
3453 3453 else 3454 3454 $post_id = url_to_postid($post); 3455 3455 3456 if ( ! $post_id ) 3456 if ( ! $post_id ) { 3457 3457 return new IXR_Error( 404, __( 'Invalid post ID.' ) ); 3458 } 3458 3459 3459 if ( ! get_post( $post_id) )3460 if ( ! get_post( $post_id ) ) { 3460 3461 return new IXR_Error( 404, __( 'Invalid post ID.' ) ); 3462 } 3461 3463 3464 if ( ! comments_open( $post_id ) ) { 3465 return new IXR_Error( 403, __( 'Sorry, comments are closed for this item.' ) ); 3466 } 3467 3462 3468 $comment = array(); 3463 3469 $comment['comment_post_ID'] = $post_id; 3464 3470 3465 3471 if ( $logged_in ) { 3466 $comment['comment_author'] = $this->escape( $user->display_name ); 3467 $comment['comment_author_email'] = $this->escape( $user->user_email ); 3468 $comment['comment_author_url'] = $this->escape( $user->user_url ); 3472 $display_name = $user->display_name; 3473 $user_email = $user->user_email; 3474 $user_url = $user->user_url; 3475 3476 $comment['comment_author'] = $this->escape( $display_name ); 3477 $comment['comment_author_email'] = $this->escape( $user_email ); 3478 $comment['comment_author_url'] = $this->escape( $user_url ); 3469 3479 $comment['user_ID'] = $user->ID; 3470 3480 } else { 3471 3481 $comment['comment_author'] = ''; -
tests/phpunit/tests/xmlrpc/wp/newComment.php
1 <?php 2 3 /** 4 * @group xmlrpc 5 */ 6 class Tests_XMLRPC_wp_newComment extends WP_XMLRPC_UnitTestCase { 7 function test_new_comment_post_closed() { 8 $this->make_user_by_role( 'administrator' ); 9 $post = $this->factory->post->create_and_get( array( 10 'comment_status' => 'closed' 11 ) ); 12 13 $this->assertEquals( 'closed', $post->comment_status ); 14 15 $result = $this->myxmlrpcserver->wp_newComment( array( 1, 'administrator', 'administrator', $post->ID, array( 16 'comment_content' => rand_str( 100 ), 17 'status' => 'approved' 18 ) ) ); 19 20 $this->assertInstanceOf( 'IXR_Error', $result ); 21 $this->assertEquals( 403, $result->code ); 22 } 23 } 24 No newline at end of file