Comments: Use correct orderby parameter name in personal data exporter and eraser.

This ensures that `get_comments()` is called with the correct parameter name in:
* `wp_comments_personal_data_exporter()`
* `wp_comments_personal_data_eraser()`

Follow-up to [42888], [42994].

Props smeunus, kapilpaul, SergeyBiryukov.
Fixes #57700.

git-svn-id: https://develop.svn.wordpress.org/trunk@55324 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Sergey Biryukov 2023-02-13 22:03:30 +00:00
parent b487e4c611
commit c07b57c693
3 changed files with 60 additions and 2 deletions

View File

@ -3692,7 +3692,7 @@ function wp_comments_personal_data_exporter( $email_address, $page = 1 ) {
'author_email' => $email_address,
'number' => $number,
'paged' => $page,
'order_by' => 'comment_ID',
'orderby' => 'comment_ID',
'order' => 'ASC',
'update_comment_meta_cache' => false,
)
@ -3815,7 +3815,7 @@ function wp_comments_personal_data_eraser( $email_address, $page = 1 ) {
'author_email' => $email_address,
'number' => $number,
'paged' => $page,
'order_by' => 'comment_ID',
'orderby' => 'comment_ID',
'order' => 'ASC',
'include_unapproved' => true,
)

View File

@ -229,4 +229,33 @@ class Tests_Comment_wpCommentsPersonalDataEraser extends WP_UnitTestCase {
public function wp_anonymize_comment_custom_message( $anonymize, $comment, $anonymized_comment ) {
return sprintf( 'Some custom message for comment %d.', $comment->comment_ID );
}
/**
* Testing that `wp_comments_personal_data_eraser()` orders comments by ID.
*
* @ticket 57700
*/
public function test_wp_comments_personal_data_eraser_orders_comments_by_id() {
$args = array(
'comment_post_ID' => self::$post_id,
'comment_author' => 'Comment Author',
'comment_author_email' => 'personal@local.host',
'comment_author_url' => 'https://local.host/',
'comment_author_IP' => '192.168.0.1',
'comment_date' => '2018-04-14 17:20:00',
'comment_agent' => 'COMMENT_AGENT',
'comment_content' => 'Comment Content',
);
self::factory()->comment->create( $args );
$filter = new MockAction();
add_filter( 'comments_clauses', array( &$filter, 'filter' ) );
wp_comments_personal_data_eraser( $args['comment_author_email'] );
$clauses = $filter->get_args()[0][0];
$this->assertStringContainsString( 'comment_ID', $clauses['orderby'] );
}
}

View File

@ -132,4 +132,33 @@ class Tests_Comment_wpCommentsPersonalDataExporter extends WP_UnitTestCase {
// Number of exported comments.
$this->assertCount( 0, $actual['data'] );
}
/**
* Testing that `wp_comments_personal_data_exporter()` orders comments by ID.
*
* @ticket 57700
*/
public function test_wp_comments_personal_data_exporter_orders_comments_by_id() {
$args = array(
'comment_post_ID' => self::$post_id,
'comment_author' => 'Comment Author',
'comment_author_email' => 'personal@local.host',
'comment_author_url' => 'https://local.host/',
'comment_author_IP' => '192.168.0.1',
'comment_date' => '2018-03-28 20:05:00',
'comment_agent' => 'SOME_AGENT',
'comment_content' => 'Comment',
);
self::factory()->comment->create( $args );
$filter = new MockAction();
add_filter( 'comments_clauses', array( &$filter, 'filter' ) );
wp_comments_personal_data_exporter( $args['comment_author_email'] );
$clauses = $filter->get_args()[0][0];
$this->assertStringContainsString( 'comment_ID', $clauses['orderby'] );
}
}