Make WordPress Core

Changeset 31171


Ignore:
Timestamp:
01/13/2015 06:41:19 AM (9 years ago)
Author:
SergeyBiryukov
Message:

Add 'comment_type' to the list of fields wp_update_comment() can update.

props desaiuditd.
fixes #30627.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/comment.php

    r31150 r31171  
    22402240    $comment_ID = $data['comment_ID'];
    22412241    $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' );
     2242    $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' );
    22432243    $data = wp_array_slice_assoc( $data, $keys );
    22442244    $rval = $wpdb->update( $wpdb->comments, $data, compact( 'comment_ID' ) );
  • trunk/tests/phpunit/tests/comment.php

    r30402 r31171  
    1414        $result = wp_update_comment( array( 'comment_ID' => $comments[0], 'comment_parent' => $comments[1] ) );
    1515        $this->assertEquals( 0, $result );
     16    }
     17
     18    /**
     19     * @ticket 30627
     20     */
     21    function test_wp_update_comment_updates_comment_type() {
     22        $post_id = $this->factory->post->create();
     23        $comment_id = $this->factory->comment->create( array( 'comment_post_ID' => $post_id ) );
     24
     25        wp_update_comment( array( 'comment_ID' => $comment_id, 'comment_type' => 'pingback' ) );
     26
     27        $comment = get_comment( $comment_id );
     28        $this->assertEquals( 'pingback', $comment->comment_type );
    1629    }
    1730
Note: See TracChangeset for help on using the changeset viewer.