Issue #3186752 by longwave, ravi.shankar, jonathanshaw, g-brodiei: Deprecate langcode argument to _user_mail_notify()

merge-requests/123/head
Alex Pott 2020-12-09 13:42:23 +00:00
parent 4823b803ea
commit ab50d1b243
No known key found for this signature in database
GPG Key ID: 31905460D4A69276
3 changed files with 20 additions and 3 deletions

View File

@ -259,7 +259,7 @@ class UserAuthenticationController extends ControllerBase implements ContainerIn
}
// Send the password reset email.
$mail = _user_mail_notify('password_reset', $account, $account->getPreferredLangcode());
$mail = _user_mail_notify('password_reset', $account);
if (empty($mail)) {
throw new BadRequestHttpException('Unable to send email. Contact the site administrator if the problem persists.');
}

View File

@ -94,4 +94,15 @@ class UserMailNotifyTest extends EntityKernelTestBase {
$this->assertEmpty($this->getMails());
}
/**
* Tests the deprecated $langcode argument to _user_mail_notify().
*
* @group legacy
*/
public function testUserMailNotifyLangcodeDeprecation() {
$account = $this->createUser();
$this->expectDeprecation('Specifying the notification language using the $langcode parameter is deprecated in drupal:9.2.0 and is removed from drupal:10.0.0. Omit the parameter. See https://www.drupal.org/node/3187082');
_user_mail_notify('password_reset', $account, $account->getPreferredLangcode());
}
}

View File

@ -1030,8 +1030,10 @@ function user_role_revoke_permissions($rid, array $permissions = []) {
* The user object of the account being notified. Must contain at
* least the fields 'uid', 'name', and 'mail'.
* @param string $langcode
* (optional) Language code to use for the notification, overriding account
* language.
* (deprecated) (optional) Language code to use for the notification,
* overriding account language. Specifying the notification language using
* the $langcode parameter is deprecated in drupal:9.2.0 and is removed from
* drupal:10.0.0. Omit the parameter. See https://www.drupal.org/node/3187082
*
* @return array
* An array containing various information about the message.
@ -1040,6 +1042,10 @@ function user_role_revoke_permissions($rid, array $permissions = []) {
* @see user_mail_tokens()
*/
function _user_mail_notify($op, AccountInterface $account, $langcode = NULL) {
if ($langcode) {
@trigger_error('Specifying the notification language using the $langcode parameter is deprecated in drupal:9.2.0 and is removed from drupal:10.0.0. Omit the parameter. See https://www.drupal.org/node/3187082', E_USER_DEPRECATED);
}
if (\Drupal::config('user.settings')->get('notify.' . $op)) {
$params['account'] = $account;
$langcode = $langcode ? $langcode : $account->getPreferredLangcode();