Ticket #44550: 44550.3.diff
File 44550.3.diff, 4.4 KB (added by , 6 years ago) |
---|
-
src/wp-includes/user.php
3368 3368 } 3369 3369 3370 3370 // Localize message content for user; fallback to site default for visitors. 3371 $saved_locale = ''; 3371 3372 if ( ! empty( $request->user_id ) ) { 3372 $locale = get_user_locale( $request->user_id ); 3373 $locale = get_user_locale( $request->user_id ); 3374 $saved_locale = get_user_meta( $request->user_id, 'locale', true ); 3373 3375 } else { 3374 3376 $locale = get_locale(); 3375 3377 } 3376 3378 3379 $confirm_url = add_query_arg( array( 3380 'action' => 'confirmaction', 3381 'request_id' => $request_id, 3382 'confirm_key' => wp_generate_user_request_key( $request_id ), 3383 ), wp_login_url() ); 3384 3385 // Include locale in the confirmation URL when the user has selected one. 3386 if ( ! empty( $saved_locale ) ) { 3387 $confirm_url = add_query_arg( 'wp_lang', $saved_locale, $confirm_url ); 3388 } 3389 3377 3390 $switched_locale = switch_to_locale( $locale ); 3378 3391 3379 3392 $email_data = array( … … 3380 3393 'request' => $request, 3381 3394 'email' => $request->email, 3382 3395 'description' => wp_user_request_action_description( $request->action_name ), 3383 'confirm_url' => add_query_arg( array( 3384 'action' => 'confirmaction', 3385 'request_id' => $request_id, 3386 'confirm_key' => wp_generate_user_request_key( $request_id ), 3387 ), wp_login_url() ), 3396 'confirm_url' => $confirm_url, 3388 3397 'sitename' => wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES ), 3389 3398 'siteurl' => home_url(), 3390 3399 ); -
src/wp-login.php
898 898 899 899 login_header( __( 'User action confirmed.' ), $message ); 900 900 login_footer(); 901 902 if ( $switched_locale ) { 903 restore_previous_locale(); 904 } 905 901 906 exit; 902 907 903 908 case 'login': -
tests/phpunit/tests/user/wpSendUserRequest.php
259 259 $mailer = tests_retrieve_phpmailer_instance(); 260 260 261 261 $this->assertContains( 'Confirma la', $mailer->get_sent()->subject ); 262 $this->assertContains( 'wp_lang=es_ES', $mailer->get_sent()->body ); 262 263 } 263 264 264 265 /** … … 281 282 $mailer = tests_retrieve_phpmailer_instance(); 282 283 283 284 $this->assertContains( 'Aktion bestätigen', $mailer->get_sent()->subject ); 285 $this->assertContains( 'wp_lang=de_DE', $mailer->get_sent()->body ); 284 286 } 285 287 286 288 /** … … 303 305 $mailer = tests_retrieve_phpmailer_instance(); 304 306 305 307 $this->assertContains( 'Confirma la', $mailer->get_sent()->subject ); 308 $this->assertNotContains( 'wp_lang=', $mailer->get_sent()->body ); 306 309 } 307 310 308 311 /** … … 327 330 $mailer = tests_retrieve_phpmailer_instance(); 328 331 329 332 $this->assertContains( 'Confirm Action', $mailer->get_sent()->subject ); 333 $this->assertContains( 'wp_lang=en_US', $mailer->get_sent()->body ); 330 334 } 331 335 332 336 /** … … 346 350 $mailer = tests_retrieve_phpmailer_instance(); 347 351 348 352 $this->assertContains( 'Confirm Action', $mailer->get_sent()->subject ); 353 $this->assertNotContains( 'wp_lang=', $mailer->get_sent()->body ); 349 354 } 350 355 351 356 /** … … 368 373 $mailer = tests_retrieve_phpmailer_instance(); 369 374 370 375 $this->assertContains( 'Confirma la', $mailer->get_sent()->subject ); 376 $this->assertNotContains( 'wp_lang=', $mailer->get_sent()->body ); 371 377 } 378 379 /** 380 * The function should respect the user locale settings when they have selected a specific locale on their 381 * profile and the site's default is the same. 382 * 383 * @ticket 44550 384 * @group l10n 385 */ 386 public function test_should_send_user_request_email_in_user_locale_when_user_and_site_share_locale() { 387 update_option( 'WPLANG', 'de_DE' ); 388 switch_to_locale( 'de_DE' ); 389 390 update_user_meta( self::$test_user->ID, 'locale', 'de_DE' ); 391 update_user_meta( self::$admin_user->ID, 'locale', 'es_ES' ); 392 393 wp_set_current_user( self::$admin_user->ID ); 394 395 $request_id = wp_create_user_request( self::$test_user->user_email, 'erase_personal_data' ); 396 397 wp_send_user_request( $request_id ); 398 $mailer = tests_retrieve_phpmailer_instance(); 399 $this->assertContains( 'Aktion bestätigen', $mailer->get_sent()->subject ); 400 $this->assertContains( 'wp_lang=de_DE', $mailer->get_sent()->body ); 401 } 372 402 }