diff options
author | Sergey Biryukov <sergeybiryukov@git.wordpress.org> | 2023-02-13 22:03:30 +0000 |
---|---|---|
committer | Sergey Biryukov <sergeybiryukov@git.wordpress.org> | 2023-02-13 22:03:30 +0000 |
commit | c07b57c69311e79c96e24cb104be73aacb8c635c (patch) | |
tree | 6677efd508795f7936438f8c4391f15fb4fb8e3c | |
parent | b487e4c611003b2bab89ef76442927f4b2d83a20 (diff) | |
download | wordpress-c07b57c69311e79c96e24cb104be73aacb8c635c.tar.gz wordpress-c07b57c69311e79c96e24cb104be73aacb8c635c.zip |
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
-rw-r--r-- | src/wp-includes/comment.php | 4 | ||||
-rw-r--r-- | tests/phpunit/tests/comment/wpCommentsPersonalDataEraser.php | 29 | ||||
-rw-r--r-- | tests/phpunit/tests/comment/wpCommentsPersonalDataExporter.php | 29 |
3 files changed, 60 insertions, 2 deletions
diff --git a/src/wp-includes/comment.php b/src/wp-includes/comment.php index d09dc4967c..a16a33c132 100644 --- a/src/wp-includes/comment.php +++ b/src/wp-includes/comment.php @@ -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, ) diff --git a/tests/phpunit/tests/comment/wpCommentsPersonalDataEraser.php b/tests/phpunit/tests/comment/wpCommentsPersonalDataEraser.php index c5d3312e79..ef7ccc4091 100644 --- a/tests/phpunit/tests/comment/wpCommentsPersonalDataEraser.php +++ b/tests/phpunit/tests/comment/wpCommentsPersonalDataEraser.php @@ -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'] ); + } } diff --git a/tests/phpunit/tests/comment/wpCommentsPersonalDataExporter.php b/tests/phpunit/tests/comment/wpCommentsPersonalDataExporter.php index ad60ccceeb..f3fce0f804 100644 --- a/tests/phpunit/tests/comment/wpCommentsPersonalDataExporter.php +++ b/tests/phpunit/tests/comment/wpCommentsPersonalDataExporter.php @@ -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'] ); + } } |