WordPress.org

Make WordPress Core

Ticket #46302: 48431.diff

File 48431.diff, 9.5 KB (added by garrett-eclipse, 12 months ago)

Initial patch to correct the wp_get_user_request_data function as it returns the request and not the request_data which is a property of the WP_User_Request

  • src/wp-admin/includes/ajax-actions.php

     
    47104710
    47114711        check_ajax_referer( 'wp-privacy-export-personal-data-' . $request_id, 'security' );
    47124712
    4713         // Get the request data.
    4714         $request = wp_get_user_request_data( $request_id );
     4713        // Get the request.
     4714        $request = wp_get_user_request( $request_id );
    47154715
    47164716        if ( ! $request || 'export_personal_data' !== $request->action_name ) {
    47174717                wp_send_json_error( __( 'Invalid request type.' ) );
     
    49014901
    49024902        check_ajax_referer( 'wp-privacy-erase-personal-data-' . $request_id, 'security' );
    49034903
    4904         // Get the request data.
    4905         $request = wp_get_user_request_data( $request_id );
     4904        // Get the request.
     4905        $request = wp_get_user_request( $request_id );
    49064906
    49074907        if ( ! $request || 'remove_personal_data' !== $request->action_name ) {
    49084908                wp_send_json_error( __( 'Invalid request type.' ) );
  • src/wp-admin/includes/class-wp-privacy-requests-table.php

     
    302302                $requests       = $requests_query->posts;
    303303
    304304                foreach ( $requests as $request ) {
    305                         $this->items[] = wp_get_user_request_data( $request->ID );
     305                        $this->items[] = wp_get_user_request( $request->ID );
    306306                }
    307307
    308308                $this->items = array_filter( $this->items );
  • src/wp-admin/includes/deprecated.php

     
    15631563function _wp_privacy_requests_screen_options() {
    15641564        _deprecated_function( __FUNCTION__, '5.3.0' );
    15651565}
     1566
     1567/**
     1568 * Return the user request object for the specified request ID.
     1569 *
     1570 * @since 4.9.6
     1571 * @deprecated 5.4.0 Use wp_get_user_request()
     1572 * @see wp_get_user_request()
     1573 *
     1574 * @param int $request_id The ID of the user request.
     1575 * @return WP_User_Request|false
     1576 */
     1577function wp_get_user_request_data( $request_id ) {
     1578        _deprecated_function( __FUNCTION__, '5.4.0', 'wp_get_user_request()' );
     1579        return wp_get_user_request( $request_id );
     1580}
     1581 No newline at end of file
  • src/wp-admin/includes/privacy-tools.php

     
    4444 * @return int|WP_Error $result Request ID on success or WP_Error.
    4545 */
    4646function _wp_privacy_completed_request( $request_id ) {
     47        // Get the request.
    4748        $request_id = absint( $request_id );
    48         $request    = wp_get_user_request_data( $request_id );
     49        $request    = wp_get_user_request( $request_id );
    4950
    5051        if ( ! $request ) {
    5152                return new WP_Error( 'privacy_request_error', __( 'Invalid request.' ) );
     
    288289                wp_send_json_error( __( 'Unable to generate export file. ZipArchive not available.' ) );
    289290        }
    290291
    291         // Get the request data.
    292         $request = wp_get_user_request_data( $request_id );
     292        // Get the request.
     293        $request = wp_get_user_request( $request_id );
    293294
    294295        if ( ! $request || 'export_personal_data' !== $request->action_name ) {
    295296                wp_send_json_error( __( 'Invalid request ID when generating export file.' ) );
     
    499500 * @return true|WP_Error True on success or `WP_Error` on failure.
    500501 */
    501502function wp_privacy_send_personal_data_export_email( $request_id ) {
    502         // Get the request data.
    503         $request = wp_get_user_request_data( $request_id );
     503        // Get the request.
     504        $request = wp_get_user_request( $request_id );
    504505
    505506        if ( ! $request || 'export_personal_data' !== $request->action_name ) {
    506507                return new WP_Error( 'invalid_request', __( 'Invalid request ID when sending personal data export email.' ) );
     
    669670                return $response;
    670671        }
    671672
    672         // Get the request data.
    673         $request = wp_get_user_request_data( $request_id );
     673        // Get the request.
     674        $request = wp_get_user_request( $request_id );
    674675
    675676        if ( ! $request || 'export_personal_data' !== $request->action_name ) {
    676677                wp_send_json_error( __( 'Invalid request ID when merging exporter data.' ) );
     
    813814                return $response;
    814815        }
    815816
    816         $request = wp_get_user_request_data( $request_id );
     817        // Get the request.
     818        $request = wp_get_user_request( $request_id );
    817819
    818820        if ( ! $request || 'remove_personal_data' !== $request->action_name ) {
    819821                wp_send_json_error( __( 'Invalid request ID when processing eraser data.' ) );
  • src/wp-includes/user.php

     
    30273027 * @param int $request_id ID of the request.
    30283028 */
    30293029function _wp_privacy_account_request_confirmed( $request_id ) {
    3030         $request = wp_get_user_request_data( $request_id );
     3030        $request = wp_get_user_request( $request_id );
    30313031
    30323032        if ( ! $request ) {
    30333033                return;
     
    30573057 * @param int $request_id The ID of the request.
    30583058 */
    30593059function _wp_privacy_send_request_confirmation_notification( $request_id ) {
    3060         $request = wp_get_user_request_data( $request_id );
     3060        $request = wp_get_user_request( $request_id );
    30613061
    30623062        if ( ! is_a( $request, 'WP_User_Request' ) || 'request-confirmed' !== $request->status ) {
    30633063                return;
     
    31963196 * @param int $request_id The privacy request post ID associated with this request.
    31973197 */
    31983198function _wp_privacy_send_erasure_fulfillment_notification( $request_id ) {
    3199         $request = wp_get_user_request_data( $request_id );
     3199        $request = wp_get_user_request( $request_id );
    32003200
    32013201        if ( ! is_a( $request, 'WP_User_Request' ) || 'request-completed' !== $request->status ) {
    32023202                return;
     
    33463346 * @return string $message The confirmation message.
    33473347 */
    33483348function _wp_privacy_account_request_confirmed_message( $request_id ) {
    3349         $request = wp_get_user_request_data( $request_id );
     3349        $request = wp_get_user_request( $request_id );
    33503350
    33513351        $message  = '<p class="success">' . __( 'Action has been confirmed.' ) . '</p>';
    33523352        $message .= '<p>' . __( 'The site administrator has been notified and will fulfill your request as soon as possible.' ) . '</p>';
     
    34823482 */
    34833483function wp_send_user_request( $request_id ) {
    34843484        $request_id = absint( $request_id );
    3485         $request    = wp_get_user_request_data( $request_id );
     3485        $request    = wp_get_user_request( $request_id );
    34863486
    34873487        if ( ! $request ) {
    34883488                return new WP_Error( 'invalid_request', __( 'Invalid user request.' ) );
     
    36443644        global $wp_hasher;
    36453645
    36463646        $request_id = absint( $request_id );
    3647         $request    = wp_get_user_request_data( $request_id );
     3647        $request    = wp_get_user_request( $request_id );
    36483648
    36493649        if ( ! $request ) {
    36503650                return new WP_Error( 'invalid_request', __( 'Invalid request.' ) );
     
    36963696}
    36973697
    36983698/**
    3699  * Return data about a user request.
     3699 * Return the user request object for the specified request ID.
    37003700 *
    37013701 * @since 4.9.6
    37023702 *
    3703  * @param int $request_id Request ID to get data about.
     3703 * @param int $request_id The ID of the user request.
    37043704 * @return WP_User_Request|false
    37053705 */
    3706 function wp_get_user_request_data( $request_id ) {
     3706function wp_get_user_request( $request_id ) {
    37073707        $request_id = absint( $request_id );
    37083708        $post       = get_post( $request_id );
    37093709
  • tests/phpunit/tests/privacy/wpPrivacyGeneratePersonalDataExportFile.php

     
    258258                $this->assertTrue( file_exists( $report_dir . 'index.html' ) );
    259259
    260260                $report_contents = file_get_contents( $report_dir . 'index.html' );
    261                 $request         = wp_get_user_request_data( self::$export_request_id );
     261                $request         = wp_get_user_request( self::$export_request_id );
    262262
    263263                $this->assertContains( '<h1>Personal Data Export</h1>', $report_contents );
    264264                $this->assertContains( '<h2>About</h2>', $report_contents );
     
    285285                $zip->extractTo( $report_dir );
    286286                $zip->close();
    287287
    288                 $request = wp_get_user_request_data( self::$export_request_id );
     288                $request = wp_get_user_request( self::$export_request_id );
    289289
    290290                $this->assertTrue( file_exists( $report_dir . 'export.json' ) );
    291291
  • tests/phpunit/tests/privacy/wpPrivacySendRequestConfirmationNotification.php

     
    152152        }
    153153
    154154        /**
    155          * Filter callback that modifies the recipient of the data request confirmation notification.
     155         * Filter callback that modifies the recipient of the user request confirmation notification.
    156156         *
    157157         * @since 4.9.8
    158158         *
    159159         * @param string          $admin_email  The email address of the notification recipient.
    160          * @param WP_User_Request $request_data The request that is initiating the notification.
     160         * @param WP_User_Request $request The request that is initiating the notification.
    161161         * @return string Admin email address.
    162162         */
    163         public function modify_email_address( $admin_email, $request_data ) {
    164                 $admin_email = $request_data->email;
     163        public function modify_email_address( $admin_email, $request ) {
     164                $admin_email = $request->email;
    165165                return $admin_email;
    166166        }
    167167