Privacy: Ensure the privacy data erase fulfillment email is sent in the locale of the user whose data is being erased (or the site's default locale if they are not a registered user) when the administrator fulfilling the request uses a different locale.
Props desrosj, birgire, garrett-eclipse. Fixes #44721. git-svn-id: https://develop.svn.wordpress.org/trunk@45039 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
e2aa3c5efe
commit
b957460b7b
|
@ -3140,6 +3140,15 @@ function _wp_privacy_send_erasure_fulfillment_notification( $request_id ) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Localize message content for user; fallback to site default for visitors.
|
||||||
|
if ( ! empty( $request->user_id ) ) {
|
||||||
|
$locale = get_user_locale( $request->user_id );
|
||||||
|
} else {
|
||||||
|
$locale = get_locale();
|
||||||
|
}
|
||||||
|
|
||||||
|
$switched_locale = switch_to_locale( $locale );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Filters the recipient of the data erasure fulfillment notification.
|
* Filters the recipient of the data erasure fulfillment notification.
|
||||||
*
|
*
|
||||||
|
@ -3250,6 +3259,10 @@ All at ###SITENAME###
|
||||||
|
|
||||||
$email_sent = wp_mail( $user_email, $subject, $content );
|
$email_sent = wp_mail( $user_email, $subject, $content );
|
||||||
|
|
||||||
|
if ( $switched_locale ) {
|
||||||
|
restore_previous_locale();
|
||||||
|
}
|
||||||
|
|
||||||
if ( $email_sent ) {
|
if ( $email_sent ) {
|
||||||
update_post_meta( $request_id, '_wp_user_notified', true );
|
update_post_meta( $request_id, '_wp_user_notified', true );
|
||||||
}
|
}
|
||||||
|
|
Binary file not shown.
|
@ -2,13 +2,13 @@
|
||||||
# This file is distributed under the same license as the 4.9.x package.
|
# This file is distributed under the same license as the 4.9.x package.
|
||||||
msgid ""
|
msgid ""
|
||||||
msgstr ""
|
msgstr ""
|
||||||
"PO-Revision-Date: 2018-08-13 19:19+0300\n"
|
"PO-Revision-Date: 2019-03-27 22:27+0300\n"
|
||||||
"MIME-Version: 1.0\n"
|
"MIME-Version: 1.0\n"
|
||||||
"Content-Type: text/plain; charset=UTF-8\n"
|
"Content-Type: text/plain; charset=UTF-8\n"
|
||||||
"Content-Transfer-Encoding: 8bit\n"
|
"Content-Transfer-Encoding: 8bit\n"
|
||||||
"Plural-Forms: nplurals=2; plural=n != 1;\n"
|
"Plural-Forms: nplurals=2; plural=n != 1;\n"
|
||||||
"X-Generator: Poedit 2.1.1\n"
|
"X-Generator: Poedit 2.2.1\n"
|
||||||
"Project-Id-Version: Development (4.9.x)\n"
|
"Project-Id-Version: Development (5.2.x)\n"
|
||||||
"Language: de_DE\n"
|
"Language: de_DE\n"
|
||||||
"POT-Creation-Date: \n"
|
"POT-Creation-Date: \n"
|
||||||
"Last-Translator: \n"
|
"Last-Translator: \n"
|
||||||
|
@ -48,3 +48,8 @@ msgstr "Jetzt %s aktualisieren"
|
||||||
#: wp-includes/user.php:3445
|
#: wp-includes/user.php:3445
|
||||||
msgid "[%1$s] Confirm Action: %2$s"
|
msgid "[%1$s] Confirm Action: %2$s"
|
||||||
msgstr "[%1$s] Aktion bestätigen: %2$s"
|
msgstr "[%1$s] Aktion bestätigen: %2$s"
|
||||||
|
|
||||||
|
#. translators: %s: Site name.
|
||||||
|
#: wp-includes/user.php:3175
|
||||||
|
msgid "[%s] Erasure Request Fulfilled"
|
||||||
|
msgstr "[%s] Löschauftrag ausgeführt"
|
||||||
|
|
Binary file not shown.
|
@ -2,13 +2,13 @@
|
||||||
# This file is distributed under the same license as the Development (4.9.x) package.
|
# This file is distributed under the same license as the Development (4.9.x) package.
|
||||||
msgid ""
|
msgid ""
|
||||||
msgstr ""
|
msgstr ""
|
||||||
"PO-Revision-Date: 2018-08-13 19:19+0300\n"
|
"PO-Revision-Date: 2019-03-27 22:27+0300\n"
|
||||||
"MIME-Version: 1.0\n"
|
"MIME-Version: 1.0\n"
|
||||||
"Content-Type: text/plain; charset=UTF-8\n"
|
"Content-Type: text/plain; charset=UTF-8\n"
|
||||||
"Content-Transfer-Encoding: 8bit\n"
|
"Content-Transfer-Encoding: 8bit\n"
|
||||||
"Plural-Forms: nplurals=2; plural=n != 1;\n"
|
"Plural-Forms: nplurals=2; plural=n != 1;\n"
|
||||||
"X-Generator: Poedit 2.1.1\n"
|
"X-Generator: Poedit 2.2.1\n"
|
||||||
"Project-Id-Version: Development (4.9.x)\n"
|
"Project-Id-Version: Development (5.2.x)\n"
|
||||||
"Language: es_ES\n"
|
"Language: es_ES\n"
|
||||||
"POT-Creation-Date: \n"
|
"POT-Creation-Date: \n"
|
||||||
"Last-Translator: \n"
|
"Last-Translator: \n"
|
||||||
|
@ -44,3 +44,8 @@ msgstr "(Actualmente fijado en: %s)"
|
||||||
#: wp-includes/user.php:3445
|
#: wp-includes/user.php:3445
|
||||||
msgid "[%1$s] Confirm Action: %2$s"
|
msgid "[%1$s] Confirm Action: %2$s"
|
||||||
msgstr "[%1$s] Confirma la acción: %2$s"
|
msgstr "[%1$s] Confirma la acción: %2$s"
|
||||||
|
|
||||||
|
#. translators: %s: Site name.
|
||||||
|
#: wp-includes/user.php:3175
|
||||||
|
msgid "[%s] Erasure Request Fulfilled"
|
||||||
|
msgstr "[%s] Solicitud de borrado completada"
|
||||||
|
|
|
@ -34,6 +34,24 @@ class Tests_Privacy_WpPrivacySendErasureFulfillmentNotification extends WP_UnitT
|
||||||
*/
|
*/
|
||||||
protected static $requester_email;
|
protected static $requester_email;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Request user.
|
||||||
|
*
|
||||||
|
* @since 5.2.0
|
||||||
|
*
|
||||||
|
* @var WP_User $request_user
|
||||||
|
*/
|
||||||
|
protected static $request_user;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test administrator user.
|
||||||
|
*
|
||||||
|
* @since 5.2.0
|
||||||
|
*
|
||||||
|
* @var WP_User $admin_user
|
||||||
|
*/
|
||||||
|
protected static $admin_user;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create user request fixtures shared by test methods.
|
* Create user request fixtures shared by test methods.
|
||||||
*
|
*
|
||||||
|
@ -43,7 +61,20 @@ class Tests_Privacy_WpPrivacySendErasureFulfillmentNotification extends WP_UnitT
|
||||||
*/
|
*/
|
||||||
public static function wpSetUpBeforeClass( $factory ) {
|
public static function wpSetUpBeforeClass( $factory ) {
|
||||||
self::$requester_email = 'erase-my-data@local.test';
|
self::$requester_email = 'erase-my-data@local.test';
|
||||||
self::$request_id = wp_create_user_request( self::$requester_email, 'erase_personal_data' );
|
self::$request_user = $factory->user->create_and_get(
|
||||||
|
array(
|
||||||
|
'user_email' => self::$requester_email,
|
||||||
|
'role' => 'subscriber',
|
||||||
|
)
|
||||||
|
);
|
||||||
|
self::$admin_user = $factory->user->create_and_get(
|
||||||
|
array(
|
||||||
|
'user_email' => 'admin@local.dev',
|
||||||
|
'role' => 'administrator',
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
self::$request_id = wp_create_user_request( self::$requester_email, 'remove_personal_data' );
|
||||||
wp_update_post(
|
wp_update_post(
|
||||||
array(
|
array(
|
||||||
'ID' => self::$request_id,
|
'ID' => self::$request_id,
|
||||||
|
@ -69,6 +100,7 @@ class Tests_Privacy_WpPrivacySendErasureFulfillmentNotification extends WP_UnitT
|
||||||
*/
|
*/
|
||||||
public function tearDown() {
|
public function tearDown() {
|
||||||
reset_phpmailer_instance();
|
reset_phpmailer_instance();
|
||||||
|
restore_previous_locale();
|
||||||
parent::tearDown();
|
parent::tearDown();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -276,4 +308,139 @@ class Tests_Privacy_WpPrivacySendErasureFulfillmentNotification extends WP_UnitT
|
||||||
$this->assertFalse( metadata_exists( 'post', self::$request_id, '_wp_user_notified' ) );
|
$this->assertFalse( metadata_exists( 'post', self::$request_id, '_wp_user_notified' ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The function should respect the user locale settings when the site uses the default locale.
|
||||||
|
*
|
||||||
|
* @since 5.2.0
|
||||||
|
* @ticket 44721
|
||||||
|
* @group l10n
|
||||||
|
*/
|
||||||
|
public function test_should_send_fulfillment_email_in_user_locale() {
|
||||||
|
update_user_meta( self::$request_user->ID, 'locale', 'es_ES' );
|
||||||
|
|
||||||
|
_wp_privacy_send_erasure_fulfillment_notification( self::$request_id );
|
||||||
|
$mailer = tests_retrieve_phpmailer_instance();
|
||||||
|
|
||||||
|
$this->assertContains( 'Solicitud de borrado completada', $mailer->get_sent()->subject );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The function should respect the user locale settings when the site does not use en_US, the administrator
|
||||||
|
* uses the site's default locale, and the user has a different locale.
|
||||||
|
*
|
||||||
|
* @since 5.2.0
|
||||||
|
* @ticket 44721
|
||||||
|
* @group l10n
|
||||||
|
*/
|
||||||
|
public function test_should_send_fulfillment_email_in_user_locale_when_site_is_not_en_us() {
|
||||||
|
update_option( 'WPLANG', 'es_ES' );
|
||||||
|
switch_to_locale( 'es_ES' );
|
||||||
|
|
||||||
|
update_user_meta( self::$request_user->ID, 'locale', 'de_DE' );
|
||||||
|
wp_set_current_user( self::$admin_user->ID );
|
||||||
|
|
||||||
|
_wp_privacy_send_erasure_fulfillment_notification( self::$request_id );
|
||||||
|
$mailer = tests_retrieve_phpmailer_instance();
|
||||||
|
|
||||||
|
$this->assertContains( 'Löschauftrag ausgeführt', $mailer->get_sent()->subject );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The function should respect the user locale settings when the site is not en_US, the administrator
|
||||||
|
* has a different selected locale, and the user uses the site's default locale.
|
||||||
|
*
|
||||||
|
* @since 5.2.0
|
||||||
|
* @ticket 44721
|
||||||
|
* @group l10n
|
||||||
|
*/
|
||||||
|
public function test_should_send_fulfillment_email_in_user_locale_when_admin_and_site_have_different_locales() {
|
||||||
|
update_option( 'WPLANG', 'es_ES' );
|
||||||
|
switch_to_locale( 'es_ES' );
|
||||||
|
|
||||||
|
update_user_meta( self::$admin_user->ID, 'locale', 'de_DE' );
|
||||||
|
wp_set_current_user( self::$admin_user->ID );
|
||||||
|
|
||||||
|
_wp_privacy_send_erasure_fulfillment_notification( self::$request_id );
|
||||||
|
$mailer = tests_retrieve_phpmailer_instance();
|
||||||
|
|
||||||
|
$this->assertContains( 'Solicitud de borrado completada', $mailer->get_sent()->subject );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The function should respect the user locale settings when the site is not en_US and both the
|
||||||
|
* administrator and the user use different locales.
|
||||||
|
*
|
||||||
|
* @since 5.2.0
|
||||||
|
* @ticket 44721
|
||||||
|
* @group l10n
|
||||||
|
*/
|
||||||
|
public function test_should_send_fulfillment_email_in_user_locale_when_both_have_different_locales_than_site() {
|
||||||
|
update_option( 'WPLANG', 'es_ES' );
|
||||||
|
switch_to_locale( 'es_ES' );
|
||||||
|
|
||||||
|
update_user_meta( self::$admin_user->ID, 'locale', 'en_US' );
|
||||||
|
update_user_meta( self::$request_user->ID, 'locale', 'de_DE' );
|
||||||
|
|
||||||
|
wp_set_current_user( self::$admin_user->ID );
|
||||||
|
|
||||||
|
_wp_privacy_send_erasure_fulfillment_notification( self::$request_id );
|
||||||
|
$mailer = tests_retrieve_phpmailer_instance();
|
||||||
|
|
||||||
|
$this->assertContains( 'Löschauftrag ausgeführt', $mailer->get_sent()->subject );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The function should respect the site's locale when the request is for an unregistered user and the
|
||||||
|
* administrator does not use the site's locale.
|
||||||
|
*
|
||||||
|
* @since 5.2.0
|
||||||
|
* @ticket 44721
|
||||||
|
* @group l10n
|
||||||
|
*/
|
||||||
|
public function test_should_send_fulfillment_email_in_site_locale() {
|
||||||
|
update_user_meta( self::$admin_user->ID, 'locale', 'es_ES' );
|
||||||
|
wp_set_current_user( self::$admin_user->ID );
|
||||||
|
|
||||||
|
$request_id = wp_create_user_request( 'erase-user-not-registered@example.com', 'remove_personal_data' );
|
||||||
|
wp_update_post(
|
||||||
|
array(
|
||||||
|
'ID' => $request_id,
|
||||||
|
'post_status' => 'request-completed',
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
_wp_privacy_send_erasure_fulfillment_notification( $request_id );
|
||||||
|
$mailer = tests_retrieve_phpmailer_instance();
|
||||||
|
|
||||||
|
$this->assertContains( 'Erasure Request Fulfilled', $mailer->get_sent()->subject );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The function should respect the site's locale when it is not en_US, the request is for an
|
||||||
|
* unregistered user, and the administrator does not use the site's default locale.
|
||||||
|
*
|
||||||
|
* @since 5.2.0
|
||||||
|
* @ticket 44721
|
||||||
|
* @group l10n
|
||||||
|
*/
|
||||||
|
public function test_should_send_fulfillment_email_in_site_locale_when_not_en_us_and_admin_has_different_locale() {
|
||||||
|
update_option( 'WPLANG', 'es_ES' );
|
||||||
|
switch_to_locale( 'es_ES' );
|
||||||
|
|
||||||
|
update_user_meta( self::$admin_user->ID, 'locale', 'de_DE' );
|
||||||
|
wp_set_current_user( self::$admin_user->ID );
|
||||||
|
|
||||||
|
$request_id = wp_create_user_request( 'erase-user-not-registered@example.com', 'remove_personal_data' );
|
||||||
|
wp_update_post(
|
||||||
|
array(
|
||||||
|
'ID' => $request_id,
|
||||||
|
'post_status' => 'request-completed',
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
_wp_privacy_send_erasure_fulfillment_notification( $request_id );
|
||||||
|
$mailer = tests_retrieve_phpmailer_instance();
|
||||||
|
|
||||||
|
$this->assertContains( 'Solicitud de borrado completada', $mailer->get_sent()->subject );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue