mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-04-05 05:04:31 +00:00
Comments: Consistently normalize user_ID to user_id in wp_new_comment().
For backward compatibility, the `user_id` parameter of `wp_new_comment()` can be spelled as `user_ID`, and plugins utilizing the `preprocess_comment` filter or the `comment_post` action should be able to receive both variations. Follow-up to [12267], [12300], [28915], [36038], [53729]. Props peterwilsoncc, SergeyBiryukov. Fixes #56244. git-svn-id: https://develop.svn.wordpress.org/trunk@54489 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -845,7 +845,6 @@ class Tests_Comment_Submission extends WP_UnitTestCase {
|
||||
* @covers ::wp_handle_comment_submission
|
||||
*/
|
||||
public function test_comment_submission_sends_all_expected_parameters_to_preprocess_comment_filter() {
|
||||
|
||||
$user = get_userdata( self::$author_id );
|
||||
wp_set_current_user( $user->ID );
|
||||
|
||||
|
||||
@@ -8,6 +8,8 @@ class Tests_Comment extends WP_UnitTestCase {
|
||||
protected static $post_id;
|
||||
protected static $notify_message = '';
|
||||
|
||||
protected $preprocess_comment_data = array();
|
||||
|
||||
public function set_up() {
|
||||
parent::set_up();
|
||||
reset_phpmailer_instance();
|
||||
@@ -456,6 +458,53 @@ class Tests_Comment extends WP_UnitTestCase {
|
||||
$this->assertSame( strlen( $comment->comment_content ), 65535 );
|
||||
}
|
||||
|
||||
/**
|
||||
* @ticket 56244
|
||||
*/
|
||||
public function test_wp_new_comment_sends_all_expected_parameters_to_preprocess_comment_filter() {
|
||||
$user = get_userdata( self::$user_id );
|
||||
wp_set_current_user( $user->ID );
|
||||
|
||||
$data = array(
|
||||
'comment_post_ID' => self::$post_id,
|
||||
'comment_author' => $user->display_name,
|
||||
'comment_author_email' => $user->user_email,
|
||||
'comment_author_url' => $user->user_url,
|
||||
'comment_content' => 'Comment',
|
||||
'comment_type' => '',
|
||||
'comment_parent' => 0,
|
||||
'user_id' => $user->ID,
|
||||
);
|
||||
|
||||
add_filter( 'preprocess_comment', array( $this, 'filter_preprocess_comment' ) );
|
||||
|
||||
$comment = wp_new_comment( $data );
|
||||
|
||||
$this->assertNotWPError( $comment );
|
||||
$this->assertSameSetsWithIndex(
|
||||
array(
|
||||
'comment_post_ID' => self::$post_id,
|
||||
'comment_author' => $user->display_name,
|
||||
'comment_author_email' => $user->user_email,
|
||||
'comment_author_url' => $user->user_url,
|
||||
'comment_content' => $data['comment_content'],
|
||||
'comment_type' => '',
|
||||
'comment_parent' => 0,
|
||||
'user_ID' => $user->ID,
|
||||
'user_id' => $user->ID,
|
||||
'comment_author_IP' => '127.0.0.1',
|
||||
'comment_agent' => '',
|
||||
),
|
||||
$this->preprocess_comment_data
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
public function filter_preprocess_comment( $commentdata ) {
|
||||
$this->preprocess_comment_data = $commentdata;
|
||||
return $commentdata;
|
||||
}
|
||||
|
||||
/**
|
||||
* @ticket 32566
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user