From b1385a8f76802e7c18d534e60e1dd2ab99f1ec9b Mon Sep 17 00:00:00 2001 From: Igor Rozum Date: Thu, 6 Aug 2026 19:43:58 -0400 Subject: [PATCH 1/2] Privacy: Add failing test for silent email-failure feedback in _wp_personal_data_handle_actions() --- .../privacy/wpPersonalDataHandleActions.php | 95 +++++++++++++++++++ 1 file changed, 95 insertions(+) create mode 100644 tests/phpunit/tests/privacy/wpPersonalDataHandleActions.php diff --git a/tests/phpunit/tests/privacy/wpPersonalDataHandleActions.php b/tests/phpunit/tests/privacy/wpPersonalDataHandleActions.php new file mode 100644 index 0000000000000..385dc1e62fdad --- /dev/null +++ b/tests/phpunit/tests/privacy/wpPersonalDataHandleActions.php @@ -0,0 +1,95 @@ +set_up_add_request_post_data( 'requester@example.com' ); + + // Cause `wp_mail()` to return false. + add_filter( 'wp_mail_from', '__return_empty_string' ); + + _wp_personal_data_handle_actions(); + + $errors = get_settings_errors( 'username_or_email_for_privacy_request' ); + + $this->assertNotEmpty( $errors, 'An error should be recorded when the confirmation email fails to send.' ); + $this->assertSame( 'error', $errors[0]['type'] ); + $this->assertSame( 'Unable to send personal data export confirmation email.', $errors[0]['message'] ); + } + + /** + * A successfully sent confirmation email should still report success. + * + * @ticket 54442 + */ + public function test_should_add_success_message_when_confirmation_email_sends() { + $this->set_up_add_request_post_data( 'requester@example.com' ); + + _wp_personal_data_handle_actions(); + + $errors = get_settings_errors( 'username_or_email_for_privacy_request' ); + + $this->assertNotEmpty( $errors ); + $this->assertSame( 'success', $errors[0]['type'] ); + $this->assertSame( 'Confirmation request initiated successfully.', $errors[0]['message'] ); + } +} From 498a6f7614879e272f59f1b884d7baaf3c7a41a9 Mon Sep 17 00:00:00 2001 From: Igor Rozum Date: Thu, 6 Aug 2026 19:43:58 -0400 Subject: [PATCH 2/2] Privacy: Surface wp_send_user_request() failures instead of a false success message --- src/wp-admin/includes/privacy-tools.php | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/wp-admin/includes/privacy-tools.php b/src/wp-admin/includes/privacy-tools.php index e7b949842ffd1..9487b33db5221 100644 --- a/src/wp-admin/includes/privacy-tools.php +++ b/src/wp-admin/includes/privacy-tools.php @@ -166,7 +166,17 @@ function _wp_personal_data_handle_actions() { } if ( 'pending' === $status ) { - wp_send_user_request( $request_id ); + $send_request_result = wp_send_user_request( $request_id ); + + if ( is_wp_error( $send_request_result ) ) { + add_settings_error( + 'username_or_email_for_privacy_request', + 'username_or_email_for_privacy_request', + $send_request_result->get_error_message(), + 'error' + ); + break; + } $message = __( 'Confirmation request initiated successfully.' ); } elseif ( 'confirmed' === $status ) {