[wp-trac] [WordPress Trac] #43985: Privacy: The user request email should be sent in the user language
WordPress Trac
noreply at wordpress.org
Fri Aug 3 18:09:27 UTC 2018
#43985: Privacy: The user request email should be sent in the user language
-------------------------------------------------+-------------------------
Reporter: Chouby | Owner: desrosj
Type: defect (bug) | Status: accepted
Priority: normal | Milestone: 4.9.9
Component: Privacy | Version: 4.9.6
Severity: normal | Resolution:
Keywords: has-patch needs-testing needs- | Focuses:
refresh needs-unit-tests | administration
-------------------------------------------------+-------------------------
Comment (by desrosj):
Ah, I forgot to do `svn add` on `wpSendUserRequest.php` test file when I
created [attachment:"43985.6.diff"].
`wp_send_user_request()` can return a `WP_Error` at the very beginning of
the function if an invalid request ID is passed. The `wp_mail()` function
will return `true`/`false`, though. I do like making the functions
consistent, so I have updated the function to return a `WP_Error` on
failure instead of `false`.
I could not reproduce the issue you described above with the email sending
in the current administrator's locale when the user is not registered. I
wrote some unit tests for each scenario that should have failed if what
you described was true, but they all passed. I dug a little deeper and
figured out the problem. `get_user_locale()` does call
`wp_get_current_user()` when the passed user ID is `0`, but it performs an
explicit check for a `0` integer. The user ID property of the
`WP_User_Request` class is being stored as a string. Since the inline
documentation for the user ID property says it is an `int`, this is
definitely a bug. I included that fix in the patch as well.
In summary, [attachment:"43985.7.diff"] contains:
- Changed `wp_send_user_request()` to return a `WP_Error` when the email
does not send successfully to match the behavior in
`wp_privacy_send_personal_data_export_email()`.
- Updated the `WP_Error` codes in `wp_get_user_request_data()`,
`wp_privacy_send_personal_data_export_email()`, and
`wp_send_user_request()` to be more descriptive and consistent when
requests are invalid and emails fail.
- Guarantee the `WP_User_Request->user_id` property is in fact an integer.
- Updated `wp_send_user_request()` to ensure the email is sent in the
requested user's locale (or the site's default locale if they are not a
registered user) when the administrator creating the request uses a
different locale. Added all necessary tests.
- Added a string to the `de_DE.po` file in order to have two non-default
locales to ensure the correct behaviors.
I also created #44721 for the fulfillment email to prevent this
patch/commit from ballooning (that function currently has no tests, so
needs more attention).
--
Ticket URL: <https://core.trac.wordpress.org/ticket/43985#comment:35>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list