Make WordPress Core

Opened 9 years ago

Last modified 10 days ago

#44084 assigned defect (bug)

Privacy: The personal data export file should be generated in the user's locale

Reported by: coreymckrill Owned by: garrett-eclipse
Priority: normal Milestone: Future Release
Component: Privacy Version: 4.9.6
Severity: normal Keywords: has-patch has-unit-tests
Cc: Focuses:

Description

Similar to #43985, the HTML file containing the personal data export should be translated into the locale the user has selected for their profile, with a fallback to the site's locale.

Attachments (3)

file.diff​ (715 bytes ) - added by vanyukov 8 years ago.
44084.diff​ (798 bytes ) - added by desrosj 8 years ago.
44084_pr15519_20261105.diff​ (13.3 KB ) - added by sawf1y 10 days ago.

Download all attachments as: .zip

Change History (39)

#1 @iandunn
9 years ago

  • Component General → Administration
  • Milestone Awaiting Review → 4.9.7
  • Status new → assigned
  • Version → trunk

#2 @iandunn
9 years ago

It'd be nice to get this in 4.9.6, but at this point it doesn't seem like there's enough time. cc @desrosj just in case you think it should be there.

#3 @desrosj
9 years ago

@iandunn I agree. Would be great, but I don't think there is enough time to test this properly. If a committer feels strongly about this for 4.9.6, they are more than welcome to see it through.

#4 @desrosj
9 years ago

  • Component Administration → Privacy

Moving to the new Privacy component.

#5 @desrosj
9 years ago

  • Version trunk → 4.9.6

Marking privacy bugs as introduced in 4.9.6.

#6 @desrosj
8 years ago

  • Milestone 4.9.7 → 4.9.8

Moving all tickets in 4.9.7 to 4.9.8.

#7 @sebakurzyn
8 years ago

  • Resolution → worksforme
  • Status assigned → closed

I already tested this bug and everything works correctly. Tested on Duch translation, single site. Email and export data have the correct language.

#8 @pento
8 years ago

  • Milestone 4.9.8

#9 @SergeyBiryukov
8 years ago

  • Milestone → 4.9.8
  • Resolution worksforme
  • Status closed → reopened

Tested with the following configuration:

  • Site's default locale: English (en_US)
  • Administrator's locale: Russian (ru_RU)
  • Editor's locale: Spanish (es_ES)

When exporting Editor's personal data, both the confirmation email and the export file use the administrator's locale (Russian in my case). Per comment:9:ticket:43985, they should use the requester's locale instead (Spanish in my case), with a fallback to the site's default locale for visitors who don't have an account.

Last edited 8 years ago by SergeyBiryukov (previous) (diff)

#10 @vanyukov
8 years ago

  • Keywords has-patch added; needs-patch removed

Added a patch. Will update the locale if the email for data export is from a valid user

#11 @desrosj
8 years ago

  • Keywords needs-testing added; gdpr removed
  • Milestone 4.9.8 → 4.9.9

#12 @desrosj
8 years ago

  • Keywords needs-unit-tests added

This ticket was mentioned in ​Slack in #core-privacy by desrosj. ​View the logs.


8 years ago

This ticket was mentioned in ​Slack in #core-privacy by desrosj. ​View the logs.


8 years ago

#15 @desrosj
8 years ago

44084.diff​ is a different approach than file.diff​.

It utilizes the user ID stored in the WP_User_Request object to prevent an unnecessary database query in get_user_by(). It also switches to the site's default locale if the current user is using a different locale, and switches back after the file is done generating.

There are a few strings not included in the actual file that are still not translated:

  • the stripped email, which has @ replaced with -at-.
  • the file basename, which is wp-personal-data-file-$stripped_email.

These two strings should probably be translated as well. But proper sanitization will need to be added for filenames with non-English characters.

Another situation to consider. An administrator can click a link to download the data export file in the admin. When that is clicked, a fresh file is generated. With 44084.diff​, the file will always be in the user's selected locale. Should the file ever be generated in the administrator's locale instead?

Tests for this change should be added to the test class being worked on in #44233. I can add those once that is committed.

Last edited 8 years ago by desrosj (previous) (diff)

This ticket was mentioned in ​Slack in #core-privacy by desrosj. ​View the logs.


8 years ago

This ticket was mentioned in ​Slack in #core-privacy by desrosj. ​View the logs.


8 years ago

#18 @idea15
8 years ago

  • Owner set to javorszky
  • Status reopened → assigned

This ticket was mentioned in ​Slack in #core-privacy by desrosj. ​View the logs.


8 years ago

This ticket was mentioned in ​Slack in #core by desrosj. ​View the logs.


8 years ago

#21 @desrosj
8 years ago

  • Keywords needs-refresh added
  • Owner changed from javorszky to desrosj

After discussion in yesterday's #core-privacy chat, it was determined that the data should be exported as follows:

  • If the user's locale matches the site's default locale, only one export file in that locale will be generated.
  • If the user's locale does not match the site's default locale, two files will be added to the ZIP file (one in each locale).
  • If the administrator's locale does not match either of these, no additional action will be performed.

This ticket was mentioned in ​Slack in #core-privacy by desrosj. ​View the logs.


8 years ago

This ticket was mentioned in ​Slack in #core-privacy by desrosj. ​View the logs.


8 years ago

#24 @pento
8 years ago

  • Milestone 4.9.9 → Future Release

This ticket was mentioned in ​Slack in #core-privacy by webdevlaw. ​View the logs.


8 years ago

This ticket was mentioned in ​Slack in #core-privacy by garrett-eclipse. ​View the logs.


7 years ago

This ticket was mentioned in ​Slack in #core-privacy by garrett-eclipse. ​View the logs.


7 years ago

#28 @desrosj
7 years ago

  • Owner desrosj removed

#29 @garrett-eclipse
7 years ago

  • Milestone Future Release → 5.5
  • Owner set to garrett-eclipse

This ticket was mentioned in ​Slack in #core by david.baumwald. ​View the logs.


6 years ago

#31 @johnbillion
6 years ago

  • Keywords needs-patch added; has-patch needs-testing needs-refresh removed

Needs a new patch as the proposed approach to this task has changed.

#32 @apedog
6 years ago

This ticket might be related. A get_admin_locale() option that is independent of the Administrator's personal-preference user locale and independent of the front-facing site locale.

#49971

This ticket was mentioned in ​Slack in #core by david.baumwald. ​View the logs.


6 years ago

#34 @desrosj
6 years ago

  • Milestone 5.5 → 5.6

With no activity in 5 weeks and beta 3 later today, I am going to punt this one. If someone can create a well rounded patch before RC1 (1 week from today), then it can be reconsidered.

#35 @garrett-eclipse
6 years ago

  • Milestone 5.6 → Future Release

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


10 days ago
#36

  • Keywords has-patch has-unit-tests added; needs-unit-tests needs-patch removed

Description

The personal data export file was generated in the locale of the administrator who clicked "Download personal data" or "Send export link", instead of the locale of the person the data belongs to.

This PR generates the export in the requester's locale. If the requester has no user account, it falls back to the site's default locale. This is the same rule the privacy emails already use (#43985, #46056).

Changes

  • wp_privacy_generate_personal_data_export_file(): switches to the requester's locale while the report is built (title, "About" group, headings, table of contents) and restores the previous locale afterwards, including on the error paths.
  • wp_ajax_wp_privacy_export_personal_data(): switches to the requester's locale around the exporter callback. Exporters return their group labels and item names already translated, and those are stored in _export_data_grouped before the file is built. Without this change, the report would mix the requester's locale (headings) with the admin's locale (data labels).

Note on the approach

Comment #21 (2018) proposed adding two files to the ZIP, one in the user's locale and one in the site's, when the two differ. Per comment #31 that approach is no longer pursued. This PR follows the "requester's locale, otherwise site locale" behaviour that core has since adopted for all privacy notifications. It also avoids running every exporter twice. Happy to revisit if the dual-file approach is still preferred.

Testing instructions

  1. Install two extra languages, e.g. Español and Deutsch.
  2. Keep the site language as English (Settings → General).
  3. Set your admin profile language to Deutsch.
  4. Create a user with profile language Español.
  5. Go to Tools → Export Personal Data, add a request for that user, and confirm it.
  6. Click "Download personal data" and open index.html in the ZIP.

Before: the report is in German, the admin's locale.
After: the report, including group labels like "Comments" and "User", is in Spanish. The admin screen stays in German.

For a requester without an account (e.g. a guest commenter's email), the report should use the site language.

Unit tests

  • Tests_Privacy_wpPrivacyGeneratePersonalDataExportFile: 3 new tests (requester locale, site-locale fallback, locale restored afterwards).
  • Tests_Ajax_wpAjaxWpPrivacyExportPersonalData: 2 new tests (exporter runs in requester locale / site locale, locale restored).

npm run test:php -- --group 44084
npm run test:php -- --group ajax --filter test_exporter_should_run

Use of AI Tools

AI assistance: Yes
Tool(s): Claude (Anthropic)
Model(s): Opus 5.5
Used for: to help write the patch and unit tests. And PR comment. All changes were reviewed, tested locally and verified by me.

Note: See TracTickets for help on using tickets.