Make WordPress Core

Opened 5 years ago

Last modified 2 months ago

#54442 new defect (bug)

Provide feedback if initiating an email for a personal data request action has failed

Reported by: ocean90 Owned by:
Priority: normal Milestone: Future Release
Component: Privacy Version: 4.9.6
Severity: normal Keywords: good-first-bug has-patch has-unit-tests
Cc: Focuses:

Description

When creating a request for an export or a delete personal data request and the confirmation email is enabled, the user doesn't get any feedback if wp_send_user_request() was successful. The function returns a WP_Error object on failure which should be checked and displayed to the user.

Source: https://core.trac.wordpress.org/browser/tags/5.8.2/src/wp-admin/includes/privacy-tools.php?marks=168-171#L168

Attachments (1)

54442.diff​ (949 bytes ) - added by hasanuzzamanshamim 5 years ago.
Error check patch created

Download all attachments as: .zip

Change History (4)

@hasanuzzamanshamim
5 years ago

Error check patch created

#1 @hasanuzzamanshamim
5 years ago

  • Keywords has-patch added

This ticket was mentioned in ​PR #4083 on ​WordPress/wordpress-develop by ​@atiqsu.


4 years ago
#2

  • Checking if request action is WP_Error, if so sending settings error to be displayed to the use
  • Updated gitignore for phpStorm IDE

The code is actually from @hasanuzzamanshamim with little update.

Trac ticket: https://core.trac.wordpress.org/ticket/54442

This ticket was mentioned in ​PR #12923 on ​WordPress/wordpress-develop by ​@irozum.


2 months ago
#3

  • Keywords has-unit-tests added

What: When an admin adds a new personal data export/erasure request with "send confirmation email" checked, _wp_personal_data_handle_actions() calls wp_send_user_request() but discards its return value, then unconditionally shows "Confirmation request initiated successfully." Since wp_send_user_request() returns a WP_Error on mail failure, the admin gets a false success message even when the confirmation email never went out — leaving the request stuck pending with no obvious explanation.

Fix: Check the return value of wp_send_user_request() and, if it's a WP_Error, surface the actual error message via add_settings_error() (type error) instead of the canned success string — mirroring the existing pattern used a few lines above for wp_create_user_request() failures and in _wp_privacy_resend_request()'s retry path.

Tests: Added tests/phpunit/tests/privacy/wpPersonalDataHandleActions.php, covering both the failure path (forcing wp_mail() to fail via the wp_mail_from filter, per the existing pattern in Tests_User_wpSendUserRequest) and the existing success path as a regression guard.

## Use of AI Tools

AI assistance: Yes
Tool(s): Claude Code
Model(s): Claude Sonnet 5
Used for: Implementation, tests, and PR description. Reviewed by Igor Rozum.

Note: See TracTickets for help on using tickets.