diff --git a/src/wp-admin/includes/ajax-actions.php b/src/wp-admin/includes/ajax-actions.php index 3eb27a324c..ea33d9d792 100644 --- a/src/wp-admin/includes/ajax-actions.php +++ b/src/wp-admin/includes/ajax-actions.php @@ -4710,8 +4710,8 @@ function wp_ajax_wp_privacy_export_personal_data() { check_ajax_referer( 'wp-privacy-export-personal-data-' . $request_id, 'security' ); - // Get the request data. - $request = wp_get_user_request_data( $request_id ); + // Get the request. + $request = wp_get_user_request( $request_id ); if ( ! $request || 'export_personal_data' !== $request->action_name ) { wp_send_json_error( __( 'Invalid request type.' ) ); @@ -4901,8 +4901,8 @@ function wp_ajax_wp_privacy_erase_personal_data() { check_ajax_referer( 'wp-privacy-erase-personal-data-' . $request_id, 'security' ); - // Get the request data. - $request = wp_get_user_request_data( $request_id ); + // Get the request. + $request = wp_get_user_request( $request_id ); if ( ! $request || 'remove_personal_data' !== $request->action_name ) { wp_send_json_error( __( 'Invalid request type.' ) ); diff --git a/src/wp-admin/includes/class-wp-privacy-requests-table.php b/src/wp-admin/includes/class-wp-privacy-requests-table.php index 744514d840..23c31b1f31 100644 --- a/src/wp-admin/includes/class-wp-privacy-requests-table.php +++ b/src/wp-admin/includes/class-wp-privacy-requests-table.php @@ -302,7 +302,7 @@ abstract class WP_Privacy_Requests_Table extends WP_List_Table { $requests = $requests_query->posts; foreach ( $requests as $request ) { - $this->items[] = wp_get_user_request_data( $request->ID ); + $this->items[] = wp_get_user_request( $request->ID ); } $this->items = array_filter( $this->items ); diff --git a/src/wp-admin/includes/deprecated.php b/src/wp-admin/includes/deprecated.php index c37d7f5537..951de39708 100644 --- a/src/wp-admin/includes/deprecated.php +++ b/src/wp-admin/includes/deprecated.php @@ -1564,3 +1564,18 @@ class WP_Privacy_Data_Removal_Requests_Table extends WP_Privacy_Data_Removal_Req function _wp_privacy_requests_screen_options() { _deprecated_function( __FUNCTION__, '5.3.0' ); } + +/** + * Return the user request object for the specified request ID. + * + * @since 4.9.6 + * @deprecated 5.4.0 Use wp_get_user_request() + * @see wp_get_user_request() + * + * @param int $request_id The ID of the user request. + * @return WP_User_Request|false + */ +function wp_get_user_request_data( $request_id ) { + _deprecated_function( __FUNCTION__, '5.4.0', 'wp_get_user_request()' ); + return wp_get_user_request( $request_id ); +} \ No newline at end of file diff --git a/src/wp-admin/includes/privacy-tools.php b/src/wp-admin/includes/privacy-tools.php index bb8a0be8a2..f246545b0e 100644 --- a/src/wp-admin/includes/privacy-tools.php +++ b/src/wp-admin/includes/privacy-tools.php @@ -41,11 +41,12 @@ function _wp_privacy_resend_request( $request_id ) { * @access private * * @param int $request_id Request ID. - * @return int|WP_Error $result Request ID on success or WP_Error. + * @return int|WP_Error $result Request ID on success or WP_Error. */ function _wp_privacy_completed_request( $request_id ) { + // Get the request. $request_id = absint( $request_id ); - $request = wp_get_user_request_data( $request_id ); + $request = wp_get_user_request( $request_id ); if ( ! $request ) { return new WP_Error( 'privacy_request_error', __( 'Invalid request.' ) ); @@ -288,8 +289,8 @@ function wp_privacy_generate_personal_data_export_file( $request_id ) { wp_send_json_error( __( 'Unable to generate export file. ZipArchive not available.' ) ); } - // Get the request data. - $request = wp_get_user_request_data( $request_id ); + // Get the request. + $request = wp_get_user_request( $request_id ); if ( ! $request || 'export_personal_data' !== $request->action_name ) { wp_send_json_error( __( 'Invalid request ID when generating export file.' ) ); @@ -501,8 +502,8 @@ function wp_privacy_generate_personal_data_export_file( $request_id ) { * @return true|WP_Error True on success or `WP_Error` on failure. */ function wp_privacy_send_personal_data_export_email( $request_id ) { - // Get the request data. - $request = wp_get_user_request_data( $request_id ); + // Get the request. + $request = wp_get_user_request( $request_id ); if ( ! $request || 'export_personal_data' !== $request->action_name ) { return new WP_Error( 'invalid_request', __( 'Invalid request ID when sending personal data export email.' ) ); @@ -671,8 +672,8 @@ function wp_privacy_process_personal_data_export_page( $response, $exporter_inde return $response; } - // Get the request data. - $request = wp_get_user_request_data( $request_id ); + // Get the request. + $request = wp_get_user_request( $request_id ); if ( ! $request || 'export_personal_data' !== $request->action_name ) { wp_send_json_error( __( 'Invalid request ID when merging exporter data.' ) ); @@ -815,7 +816,8 @@ function wp_privacy_process_personal_data_erasure_page( $response, $eraser_index return $response; } - $request = wp_get_user_request_data( $request_id ); + // Get the request. + $request = wp_get_user_request( $request_id ); if ( ! $request || 'remove_personal_data' !== $request->action_name ) { wp_send_json_error( __( 'Invalid request ID when processing eraser data.' ) ); diff --git a/src/wp-includes/user.php b/src/wp-includes/user.php index c58d290bfe..4dece3f2e9 100644 --- a/src/wp-includes/user.php +++ b/src/wp-includes/user.php @@ -3096,7 +3096,7 @@ function wp_user_personal_data_exporter( $email_address ) { * @param int $request_id ID of the request. */ function _wp_privacy_account_request_confirmed( $request_id ) { - $request = wp_get_user_request_data( $request_id ); + $request = wp_get_user_request( $request_id ); if ( ! $request ) { return; @@ -3126,7 +3126,7 @@ function _wp_privacy_account_request_confirmed( $request_id ) { * @param int $request_id The ID of the request. */ function _wp_privacy_send_request_confirmation_notification( $request_id ) { - $request = wp_get_user_request_data( $request_id ); + $request = wp_get_user_request( $request_id ); if ( ! is_a( $request, 'WP_User_Request' ) || 'request-confirmed' !== $request->status ) { return; @@ -3265,7 +3265,7 @@ All at ###SITENAME### * @param int $request_id The privacy request post ID associated with this request. */ function _wp_privacy_send_erasure_fulfillment_notification( $request_id ) { - $request = wp_get_user_request_data( $request_id ); + $request = wp_get_user_request( $request_id ); if ( ! is_a( $request, 'WP_User_Request' ) || 'request-completed' !== $request->status ) { return; @@ -3415,7 +3415,7 @@ All at ###SITENAME### * @return string $message The confirmation message. */ function _wp_privacy_account_request_confirmed_message( $request_id ) { - $request = wp_get_user_request_data( $request_id ); + $request = wp_get_user_request( $request_id ); $message = '

' . __( 'Action has been confirmed.' ) . '

'; $message .= '

' . __( 'The site administrator has been notified and will fulfill your request as soon as possible.' ) . '

'; @@ -3551,7 +3551,7 @@ function wp_user_request_action_description( $action_name ) { */ function wp_send_user_request( $request_id ) { $request_id = absint( $request_id ); - $request = wp_get_user_request_data( $request_id ); + $request = wp_get_user_request( $request_id ); if ( ! $request ) { return new WP_Error( 'invalid_request', __( 'Invalid user request.' ) ); @@ -3713,7 +3713,7 @@ function wp_validate_user_request_key( $request_id, $key ) { global $wp_hasher; $request_id = absint( $request_id ); - $request = wp_get_user_request_data( $request_id ); + $request = wp_get_user_request( $request_id ); if ( ! $request ) { return new WP_Error( 'invalid_request', __( 'Invalid request.' ) ); @@ -3765,14 +3765,14 @@ function wp_validate_user_request_key( $request_id, $key ) { } /** - * Return data about a user request. + * Return the user request object for the specified request ID. * * @since 4.9.6 * - * @param int $request_id Request ID to get data about. + * @param int $request_id The ID of the user request. * @return WP_User_Request|false */ -function wp_get_user_request_data( $request_id ) { +function wp_get_user_request( $request_id ) { $request_id = absint( $request_id ); $post = get_post( $request_id ); diff --git a/tests/phpunit/tests/privacy/wpPrivacyGeneratePersonalDataExportFile.php b/tests/phpunit/tests/privacy/wpPrivacyGeneratePersonalDataExportFile.php index c38007f498..7a4f79ed80 100644 --- a/tests/phpunit/tests/privacy/wpPrivacyGeneratePersonalDataExportFile.php +++ b/tests/phpunit/tests/privacy/wpPrivacyGeneratePersonalDataExportFile.php @@ -258,7 +258,7 @@ class Tests_Privacy_WpPrivacyGeneratePersonalDataExportFile extends WP_UnitTestC $this->assertTrue( file_exists( $report_dir . 'index.html' ) ); $report_contents = file_get_contents( $report_dir . 'index.html' ); - $request = wp_get_user_request_data( self::$export_request_id ); + $request = wp_get_user_request( self::$export_request_id ); $this->assertContains( '

Personal Data Export

', $report_contents ); $this->assertContains( '

About

', $report_contents ); @@ -285,7 +285,7 @@ class Tests_Privacy_WpPrivacyGeneratePersonalDataExportFile extends WP_UnitTestC $zip->extractTo( $report_dir ); $zip->close(); - $request = wp_get_user_request_data( self::$export_request_id ); + $request = wp_get_user_request( self::$export_request_id ); $this->assertTrue( file_exists( $report_dir . 'export.json' ) ); diff --git a/tests/phpunit/tests/privacy/wpPrivacySendRequestConfirmationNotification.php b/tests/phpunit/tests/privacy/wpPrivacySendRequestConfirmationNotification.php index 09aa8305a5..819b6bac5c 100644 --- a/tests/phpunit/tests/privacy/wpPrivacySendRequestConfirmationNotification.php +++ b/tests/phpunit/tests/privacy/wpPrivacySendRequestConfirmationNotification.php @@ -152,16 +152,16 @@ class Tests_User_WpPrivacySendRequestConfirmationNotification extends WP_UnitTes } /** - * Filter callback that modifies the recipient of the data request confirmation notification. + * Filter callback that modifies the recipient of the user request confirmation notification. * * @since 4.9.8 * * @param string $admin_email The email address of the notification recipient. - * @param WP_User_Request $request_data The request that is initiating the notification. + * @param WP_User_Request $request The request that is initiating the notification. * @return string Admin email address. */ - public function modify_email_address( $admin_email, $request_data ) { - $admin_email = $request_data->email; + public function modify_email_address( $admin_email, $request ) { + $admin_email = $request->email; return $admin_email; }