Changeset 45062
- Timestamp:
- 03/28/2019 09:28:37 PM (5 years ago)
- Location:
- trunk
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/includes/file.php
r44966 r45062 2354 2354 } 2355 2355 2356 // Localize message content for user; fallback to site default for visitors. 2357 if ( ! empty( $request->user_id ) ) { 2358 $locale = get_user_locale( $request->user_id ); 2359 } else { 2360 $locale = get_locale(); 2361 } 2362 2363 $switched_locale = switch_to_locale( $locale ); 2364 2356 2365 /** This filter is documented in wp-includes/functions.php */ 2357 2366 $expiration = apply_filters( 'wp_privacy_export_expiration', 3 * DAY_IN_SECONDS ); … … 2409 2418 $content 2410 2419 ); 2420 2421 if ( $switched_locale ) { 2422 restore_previous_locale(); 2423 } 2411 2424 2412 2425 if ( ! $mail_success ) { -
trunk/tests/phpunit/data/languages/de_DE.po
r45039 r45062 1 # Translation of 4.9.x in German2 # This file is distributed under the same license as the 4.9.x package.1 # Translation of 5.2.x in German 2 # This file is distributed under the same license as the 5.2.x package. 3 3 msgid "" 4 4 msgstr "" 5 "PO-Revision-Date: 2019-03-2 7 22:27+0300\n"5 "PO-Revision-Date: 2019-03-28 19:42+0300\n" 6 6 "MIME-Version: 1.0\n" 7 7 "Content-Type: text/plain; charset=UTF-8\n" … … 54 54 msgid "[%s] Erasure Request Fulfilled" 55 55 msgstr "[%s] Löschauftrag ausgeführt" 56 57 #: wp-admin/includes/file.php:2415 58 msgid "[%s] Personal Data Export" 59 msgstr "[%s] Export personenbezogener Daten" -
trunk/tests/phpunit/data/languages/es_ES.po
r45039 r45062 1 # Translation of Development ( 4.9.x) in Spanish (Spain)2 # This file is distributed under the same license as the Development ( 4.9.x) package.1 # Translation of Development (5.2.x) in Spanish (Spain) 2 # This file is distributed under the same license as the Development (5.2.x) package. 3 3 msgid "" 4 4 msgstr "" 5 "PO-Revision-Date: 2019-03-2 7 22:27+0300\n"5 "PO-Revision-Date: 2019-03-28 19:43+0300\n" 6 6 "MIME-Version: 1.0\n" 7 7 "Content-Type: text/plain; charset=UTF-8\n" … … 50 50 msgid "[%s] Erasure Request Fulfilled" 51 51 msgstr "[%s] Solicitud de borrado completada" 52 53 #: wp-admin/includes/file.php:2415 54 msgid "[%s] Personal Data Export" 55 msgstr "[%s] Exportación de datos personales" -
trunk/tests/phpunit/tests/privacy/wpPrivacySendPersonalDataExportEmail.php
r43568 r45062 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 * Reset the mocked phpmailer instance before each test method. 39 57 * … … 52 70 public function tearDown() { 53 71 reset_phpmailer_instance(); 72 restore_previous_locale(); 54 73 parent::tearDown(); 55 74 } … … 64 83 public static function wpSetUpBeforeClass( $factory ) { 65 84 self::$requester_email = 'requester@example.com'; 85 self::$request_user = $factory->user->create_and_get( 86 array( 87 'user_email' => self::$requester_email, 88 'role' => 'subscriber', 89 ) 90 ); 91 self::$admin_user = $factory->user->create_and_get( 92 array( 93 'user_email' => 'admin@local.dev', 94 'role' => 'administrator', 95 ) 96 ); 97 66 98 self::$request_id = wp_create_user_request( self::$requester_email, 'export_personal_data' ); 67 99 … … 168 200 return 'Custom content for request ID: ' . $request_id; 169 201 } 202 203 /** 204 * The function should respect the user locale settings when the site uses the default locale. 205 * 206 * @since 5.2.0 207 * @ticket 46056 208 * @group l10n 209 */ 210 public function test_should_send_personal_data_export_email_in_user_locale() { 211 update_user_meta( self::$request_user->ID, 'locale', 'es_ES' ); 212 213 wp_privacy_send_personal_data_export_email( self::$request_id ); 214 215 $mailer = tests_retrieve_phpmailer_instance(); 216 217 $this->assertContains( 'Exportación de datos personales', $mailer->get_sent()->subject ); 218 } 219 220 /** 221 * The function should respect the user locale settings when the site does not use en_US, the administrator 222 * uses the site's default locale, and the user has a different locale. 223 * 224 * @since 5.2.0 225 * @ticket 46056 226 * @group l10n 227 */ 228 public function test_should_send_personal_data_export_email_in_user_locale_when_site_is_not_en_us() { 229 update_option( 'WPLANG', 'es_ES' ); 230 switch_to_locale( 'es_ES' ); 231 232 update_user_meta( self::$request_user->ID, 'locale', 'de_DE' ); 233 wp_set_current_user( self::$admin_user->ID ); 234 235 wp_privacy_send_personal_data_export_email( self::$request_id ); 236 237 $mailer = tests_retrieve_phpmailer_instance(); 238 239 $this->assertContains( 'Export personenbezogener Daten', $mailer->get_sent()->subject ); 240 } 241 242 /** 243 * The function should respect the user locale settings when the site is not en_US, the administrator 244 * has a different selected locale, and the user uses the site's default locale. 245 * 246 * @since 5.2.0 247 * @ticket 46056 248 * @group l10n 249 */ 250 public function test_should_send_personal_data_export_email_in_user_locale_when_admin_and_site_have_different_locales() { 251 update_option( 'WPLANG', 'es_ES' ); 252 switch_to_locale( 'es_ES' ); 253 254 update_user_meta( self::$admin_user->ID, 'locale', 'de_DE' ); 255 wp_set_current_user( self::$admin_user->ID ); 256 257 wp_privacy_send_personal_data_export_email( self::$request_id ); 258 259 $mailer = tests_retrieve_phpmailer_instance(); 260 261 $this->assertContains( 'Exportación de datos personales', $mailer->get_sent()->subject ); 262 } 263 264 /** 265 * The function should respect the user locale settings when the site is not en_US and both the 266 * administrator and the user use different locales. 267 * 268 * @since 5.2.0 269 * @ticket 46056 270 * @group l10n 271 */ 272 public function test_should_send_personal_data_export_email_in_user_locale_when_both_have_different_locales_than_site() { 273 update_option( 'WPLANG', 'es_ES' ); 274 switch_to_locale( 'es_ES' ); 275 276 update_user_meta( self::$admin_user->ID, 'locale', 'en_US' ); 277 update_user_meta( self::$request_user->ID, 'locale', 'de_DE' ); 278 279 wp_set_current_user( self::$admin_user->ID ); 280 281 wp_privacy_send_personal_data_export_email( self::$request_id ); 282 283 $mailer = tests_retrieve_phpmailer_instance(); 284 285 $this->assertContains( 'Export personenbezogener Daten', $mailer->get_sent()->subject ); 286 } 287 288 /** 289 * The function should respect the site's locale when the request is for an unregistered user and the 290 * administrator does not use the site's locale. 291 * 292 * @since 5.2.0 293 * @ticket 46056 294 * @group l10n 295 */ 296 public function test_should_send_personal_data_export_email_in_site_locale() { 297 update_user_meta( self::$admin_user->ID, 'locale', 'es_ES' ); 298 wp_set_current_user( self::$admin_user->ID ); 299 300 $request_id = wp_create_user_request( 'export-user-not-registered@example.com', 'export_personal_data' ); 301 302 _wp_privacy_account_request_confirmed( self::$request_id ); 303 wp_privacy_send_personal_data_export_email( $request_id ); 304 305 $mailer = tests_retrieve_phpmailer_instance(); 306 307 $this->assertContains( 'Personal Data Export', $mailer->get_sent()->subject ); 308 } 309 310 /** 311 * The function should respect the site's locale when it is not en_US, the request is for an 312 * unregistered user, and the administrator does not use the site's default locale. 313 * 314 * @since 5.2.0 315 * @ticket 46056 316 * @group l10n 317 */ 318 public function test_should_send_personal_data_export_email_in_site_locale_when_not_en_us_and_admin_has_different_locale() { 319 update_option( 'WPLANG', 'es_ES' ); 320 switch_to_locale( 'es_ES' ); 321 322 update_user_meta( self::$admin_user->ID, 'locale', 'de_DE' ); 323 wp_set_current_user( self::$admin_user->ID ); 324 325 $request_id = wp_create_user_request( 'export-user-not-registered@example.com', 'export_personal_data' ); 326 327 _wp_privacy_account_request_confirmed( self::$request_id ); 328 wp_privacy_send_personal_data_export_email( $request_id ); 329 330 $mailer = tests_retrieve_phpmailer_instance(); 331 332 $this->assertContains( 'Exportación de datos personales', $mailer->get_sent()->subject ); 333 } 170 334 }
Note: See TracChangeset
for help on using the changeset viewer.