Make WordPress Core

Changeset 55324


Ignore:
Timestamp:
02/13/2023 10:03:30 PM (4 years ago)
Author:
SergeyBiryukov
Message:

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.

Location:
trunk
Files:
3 edited

Legend:

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

    r55308 r55324  
    36933693                        'number'                    => $number,
    36943694                        'paged'                     => $page,
    3695                         'order_by'                  => 'comment_ID',
     3695                        'orderby'                   => 'comment_ID',
    36963696                        'order'                     => 'ASC',
    36973697                        'update_comment_meta_cache' => false,
     
    38163816                        'number'             => $number,
    38173817                        'paged'              => $page,
    3818                         'order_by'           => 'comment_ID',
     3818                        'orderby'            => 'comment_ID',
    38193819                        'order'              => 'ASC',
    38203820                        'include_unapproved' => true,
  • trunk/tests/phpunit/tests/comment/wpCommentsPersonalDataEraser.php

    r55322 r55324  
    230230                return sprintf( 'Some custom message for comment %d.', $comment->comment_ID );
    231231        }
     232
     233        /**
     234         * Testing that `wp_comments_personal_data_eraser()` orders comments by ID.
     235         *
     236         * @ticket 57700
     237         */
     238        public function test_wp_comments_personal_data_eraser_orders_comments_by_id() {
     239
     240                $args = array(
     241                        'comment_post_ID'      => self::$post_id,
     242                        'comment_author'       => 'Comment Author',
     243                        'comment_author_email' => 'personal@local.host',
     244                        'comment_author_url'   => 'https://local.host/',
     245                        'comment_author_IP'    => '192.168.0.1',
     246                        'comment_date'         => '2018-04-14 17:20:00',
     247                        'comment_agent'        => 'COMMENT_AGENT',
     248                        'comment_content'      => 'Comment Content',
     249                );
     250                self::factory()->comment->create( $args );
     251
     252                $filter = new MockAction();
     253                add_filter( 'comments_clauses', array( &$filter, 'filter' ) );
     254
     255                wp_comments_personal_data_eraser( $args['comment_author_email'] );
     256
     257                $clauses = $filter->get_args()[0][0];
     258
     259                $this->assertStringContainsString( 'comment_ID', $clauses['orderby'] );
     260        }
    232261}
  • trunk/tests/phpunit/tests/comment/wpCommentsPersonalDataExporter.php

    r55322 r55324  
    133133                $this->assertCount( 0, $actual['data'] );
    134134        }
     135
     136        /**
     137         * Testing that `wp_comments_personal_data_exporter()` orders comments by ID.
     138         *
     139         * @ticket 57700
     140         */
     141        public function test_wp_comments_personal_data_exporter_orders_comments_by_id() {
     142
     143                $args = array(
     144                        'comment_post_ID'      => self::$post_id,
     145                        'comment_author'       => 'Comment Author',
     146                        'comment_author_email' => 'personal@local.host',
     147                        'comment_author_url'   => 'https://local.host/',
     148                        'comment_author_IP'    => '192.168.0.1',
     149                        'comment_date'         => '2018-03-28 20:05:00',
     150                        'comment_agent'        => 'SOME_AGENT',
     151                        'comment_content'      => 'Comment',
     152                );
     153                self::factory()->comment->create( $args );
     154
     155                $filter = new MockAction();
     156                add_filter( 'comments_clauses', array( &$filter, 'filter' ) );
     157
     158                wp_comments_personal_data_exporter( $args['comment_author_email'] );
     159
     160                $clauses = $filter->get_args()[0][0];
     161
     162                $this->assertStringContainsString( 'comment_ID', $clauses['orderby'] );
     163        }
    135164}
Note: See TracChangeset for help on using the changeset viewer.