Changeset 45039
- Timestamp:
- 03/27/2019 07:41:01 PM (6 years ago)
- Location:
- trunk
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/user.php
r44930 r45039 3141 3141 } 3142 3142 3143 // Localize message content for user; fallback to site default for visitors. 3144 if ( ! empty( $request->user_id ) ) { 3145 $locale = get_user_locale( $request->user_id ); 3146 } else { 3147 $locale = get_locale(); 3148 } 3149 3150 $switched_locale = switch_to_locale( $locale ); 3151 3143 3152 /** 3144 3153 * Filters the recipient of the data erasure fulfillment notification. … … 3250 3259 3251 3260 $email_sent = wp_mail( $user_email, $subject, $content ); 3261 3262 if ( $switched_locale ) { 3263 restore_previous_locale(); 3264 } 3252 3265 3253 3266 if ( $email_sent ) { -
trunk/tests/phpunit/data/languages/de_DE.po
r43568 r45039 3 3 msgid "" 4 4 msgstr "" 5 "PO-Revision-Date: 201 8-08-13 19:19+0300\n"5 "PO-Revision-Date: 2019-03-27 22:27+0300\n" 6 6 "MIME-Version: 1.0\n" 7 7 "Content-Type: text/plain; charset=UTF-8\n" 8 8 "Content-Transfer-Encoding: 8bit\n" 9 9 "Plural-Forms: nplurals=2; plural=n != 1;\n" 10 "X-Generator: Poedit 2. 1.1\n"11 "Project-Id-Version: Development ( 4.9.x)\n"10 "X-Generator: Poedit 2.2.1\n" 11 "Project-Id-Version: Development (5.2.x)\n" 12 12 "Language: de_DE\n" 13 13 "POT-Creation-Date: \n" … … 49 49 msgid "[%1$s] Confirm Action: %2$s" 50 50 msgstr "[%1$s] Aktion bestätigen: %2$s" 51 52 #. translators: %s: Site name. 53 #: wp-includes/user.php:3175 54 msgid "[%s] Erasure Request Fulfilled" 55 msgstr "[%s] Löschauftrag ausgeführt" -
trunk/tests/phpunit/data/languages/es_ES.po
r43568 r45039 3 3 msgid "" 4 4 msgstr "" 5 "PO-Revision-Date: 201 8-08-13 19:19+0300\n"5 "PO-Revision-Date: 2019-03-27 22:27+0300\n" 6 6 "MIME-Version: 1.0\n" 7 7 "Content-Type: text/plain; charset=UTF-8\n" 8 8 "Content-Transfer-Encoding: 8bit\n" 9 9 "Plural-Forms: nplurals=2; plural=n != 1;\n" 10 "X-Generator: Poedit 2. 1.1\n"11 "Project-Id-Version: Development ( 4.9.x)\n"10 "X-Generator: Poedit 2.2.1\n" 11 "Project-Id-Version: Development (5.2.x)\n" 12 12 "Language: es_ES\n" 13 13 "POT-Creation-Date: \n" … … 45 45 msgid "[%1$s] Confirm Action: %2$s" 46 46 msgstr "[%1$s] Confirma la acción: %2$s" 47 48 #. translators: %s: Site name. 49 #: wp-includes/user.php:3175 50 msgid "[%s] Erasure Request Fulfilled" 51 msgstr "[%s] Solicitud de borrado completada" -
trunk/tests/phpunit/tests/privacy/wpPrivacySendErasureFulfillmentNotification.php
r44535 r45039 36 36 37 37 /** 38 * Request user. 39 * 40 * @since 5.2.0 41 * 42 * @var WP_User $request_user 43 */ 44 protected static $request_user; 45 46 /** 47 * Test administrator user. 48 * 49 * @since 5.2.0 50 * 51 * @var WP_User $admin_user 52 */ 53 protected static $admin_user; 54 55 /** 38 56 * Create user request fixtures shared by test methods. 39 57 * … … 44 62 public static function wpSetUpBeforeClass( $factory ) { 45 63 self::$requester_email = 'erase-my-data@local.test'; 46 self::$request_id = wp_create_user_request( self::$requester_email, 'erase_personal_data' ); 64 self::$request_user = $factory->user->create_and_get( 65 array( 66 'user_email' => self::$requester_email, 67 'role' => 'subscriber', 68 ) 69 ); 70 self::$admin_user = $factory->user->create_and_get( 71 array( 72 'user_email' => 'admin@local.dev', 73 'role' => 'administrator', 74 ) 75 ); 76 77 self::$request_id = wp_create_user_request( self::$requester_email, 'remove_personal_data' ); 47 78 wp_update_post( 48 79 array( … … 70 101 public function tearDown() { 71 102 reset_phpmailer_instance(); 103 restore_previous_locale(); 72 104 parent::tearDown(); 73 105 } … … 277 309 } 278 310 311 /** 312 * The function should respect the user locale settings when the site uses the default locale. 313 * 314 * @since 5.2.0 315 * @ticket 44721 316 * @group l10n 317 */ 318 public function test_should_send_fulfillment_email_in_user_locale() { 319 update_user_meta( self::$request_user->ID, 'locale', 'es_ES' ); 320 321 _wp_privacy_send_erasure_fulfillment_notification( self::$request_id ); 322 $mailer = tests_retrieve_phpmailer_instance(); 323 324 $this->assertContains( 'Solicitud de borrado completada', $mailer->get_sent()->subject ); 325 } 326 327 /** 328 * The function should respect the user locale settings when the site does not use en_US, the administrator 329 * uses the site's default locale, and the user has a different locale. 330 * 331 * @since 5.2.0 332 * @ticket 44721 333 * @group l10n 334 */ 335 public function test_should_send_fulfillment_email_in_user_locale_when_site_is_not_en_us() { 336 update_option( 'WPLANG', 'es_ES' ); 337 switch_to_locale( 'es_ES' ); 338 339 update_user_meta( self::$request_user->ID, 'locale', 'de_DE' ); 340 wp_set_current_user( self::$admin_user->ID ); 341 342 _wp_privacy_send_erasure_fulfillment_notification( self::$request_id ); 343 $mailer = tests_retrieve_phpmailer_instance(); 344 345 $this->assertContains( 'Löschauftrag ausgeführt', $mailer->get_sent()->subject ); 346 } 347 348 /** 349 * The function should respect the user locale settings when the site is not en_US, the administrator 350 * has a different selected locale, and the user uses the site's default locale. 351 * 352 * @since 5.2.0 353 * @ticket 44721 354 * @group l10n 355 */ 356 public function test_should_send_fulfillment_email_in_user_locale_when_admin_and_site_have_different_locales() { 357 update_option( 'WPLANG', 'es_ES' ); 358 switch_to_locale( 'es_ES' ); 359 360 update_user_meta( self::$admin_user->ID, 'locale', 'de_DE' ); 361 wp_set_current_user( self::$admin_user->ID ); 362 363 _wp_privacy_send_erasure_fulfillment_notification( self::$request_id ); 364 $mailer = tests_retrieve_phpmailer_instance(); 365 366 $this->assertContains( 'Solicitud de borrado completada', $mailer->get_sent()->subject ); 367 } 368 369 /** 370 * The function should respect the user locale settings when the site is not en_US and both the 371 * administrator and the user use different locales. 372 * 373 * @since 5.2.0 374 * @ticket 44721 375 * @group l10n 376 */ 377 public function test_should_send_fulfillment_email_in_user_locale_when_both_have_different_locales_than_site() { 378 update_option( 'WPLANG', 'es_ES' ); 379 switch_to_locale( 'es_ES' ); 380 381 update_user_meta( self::$admin_user->ID, 'locale', 'en_US' ); 382 update_user_meta( self::$request_user->ID, 'locale', 'de_DE' ); 383 384 wp_set_current_user( self::$admin_user->ID ); 385 386 _wp_privacy_send_erasure_fulfillment_notification( self::$request_id ); 387 $mailer = tests_retrieve_phpmailer_instance(); 388 389 $this->assertContains( 'Löschauftrag ausgeführt', $mailer->get_sent()->subject ); 390 } 391 392 /** 393 * The function should respect the site's locale when the request is for an unregistered user and the 394 * administrator does not use the site's locale. 395 * 396 * @since 5.2.0 397 * @ticket 44721 398 * @group l10n 399 */ 400 public function test_should_send_fulfillment_email_in_site_locale() { 401 update_user_meta( self::$admin_user->ID, 'locale', 'es_ES' ); 402 wp_set_current_user( self::$admin_user->ID ); 403 404 $request_id = wp_create_user_request( 'erase-user-not-registered@example.com', 'remove_personal_data' ); 405 wp_update_post( 406 array( 407 'ID' => $request_id, 408 'post_status' => 'request-completed', 409 ) 410 ); 411 412 _wp_privacy_send_erasure_fulfillment_notification( $request_id ); 413 $mailer = tests_retrieve_phpmailer_instance(); 414 415 $this->assertContains( 'Erasure Request Fulfilled', $mailer->get_sent()->subject ); 416 } 417 418 /** 419 * The function should respect the site's locale when it is not en_US, the request is for an 420 * unregistered user, and the administrator does not use the site's default locale. 421 * 422 * @since 5.2.0 423 * @ticket 44721 424 * @group l10n 425 */ 426 public function test_should_send_fulfillment_email_in_site_locale_when_not_en_us_and_admin_has_different_locale() { 427 update_option( 'WPLANG', 'es_ES' ); 428 switch_to_locale( 'es_ES' ); 429 430 update_user_meta( self::$admin_user->ID, 'locale', 'de_DE' ); 431 wp_set_current_user( self::$admin_user->ID ); 432 433 $request_id = wp_create_user_request( 'erase-user-not-registered@example.com', 'remove_personal_data' ); 434 wp_update_post( 435 array( 436 'ID' => $request_id, 437 'post_status' => 'request-completed', 438 ) 439 ); 440 441 _wp_privacy_send_erasure_fulfillment_notification( $request_id ); 442 $mailer = tests_retrieve_phpmailer_instance(); 443 444 $this->assertContains( 'Solicitud de borrado completada', $mailer->get_sent()->subject ); 445 } 279 446 }
Note: See TracChangeset
for help on using the changeset viewer.