Add 'user_id' to the list of fields wp_update_comment() can update.
props jphase. fixes #30307. git-svn-id: https://develop.svn.wordpress.org/trunk@31172 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
a744bb9a5f
commit
819a53be46
@ -2239,7 +2239,7 @@ function wp_update_comment($commentarr) {
|
|||||||
|
|
||||||
$comment_ID = $data['comment_ID'];
|
$comment_ID = $data['comment_ID'];
|
||||||
$comment_post_ID = $data['comment_post_ID'];
|
$comment_post_ID = $data['comment_post_ID'];
|
||||||
$keys = array( 'comment_content', 'comment_author', 'comment_author_email', 'comment_approved', 'comment_karma', 'comment_author_url', 'comment_date', 'comment_date_gmt', 'comment_type', 'comment_parent' );
|
$keys = array( 'comment_content', 'comment_author', 'comment_author_email', 'comment_approved', 'comment_karma', 'comment_author_url', 'comment_date', 'comment_date_gmt', 'comment_type', 'comment_parent', 'user_id' );
|
||||||
$data = wp_array_slice_assoc( $data, $keys );
|
$data = wp_array_slice_assoc( $data, $keys );
|
||||||
$rval = $wpdb->update( $wpdb->comments, $data, compact( 'comment_ID' ) );
|
$rval = $wpdb->update( $wpdb->comments, $data, compact( 'comment_ID' ) );
|
||||||
|
|
||||||
|
@ -28,6 +28,19 @@ class Tests_Comment extends WP_UnitTestCase {
|
|||||||
$this->assertEquals( 'pingback', $comment->comment_type );
|
$this->assertEquals( 'pingback', $comment->comment_type );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ticket 30307
|
||||||
|
*/
|
||||||
|
function test_wp_update_comment_updates_user_id() {
|
||||||
|
$post_id = $this->factory->post->create();
|
||||||
|
$comment_id = $this->factory->comment->create( array( 'comment_post_ID' => $post_id ) );
|
||||||
|
|
||||||
|
wp_update_comment( array( 'comment_ID' => $comment_id, 'user_id' => 1 ) );
|
||||||
|
|
||||||
|
$comment = get_comment( $comment_id );
|
||||||
|
$this->assertEquals( 1, $comment->user_id );
|
||||||
|
}
|
||||||
|
|
||||||
public function test_get_approved_comments() {
|
public function test_get_approved_comments() {
|
||||||
$p = $this->factory->post->create();
|
$p = $this->factory->post->create();
|
||||||
$ca1 = $this->factory->comment->create( array( 'comment_post_ID' => $p, 'comment_approved' => '1' ) );
|
$ca1 = $this->factory->comment->create( array( 'comment_post_ID' => $p, 'comment_approved' => '1' ) );
|
||||||
|
Loading…
Reference in New Issue
Block a user