Unverified Commit ab50d1b2 authored by Alex Pott's avatar Alex Pott
Browse files

Issue #3186752 by longwave, ravi.shankar, jonathanshaw, g-brodiei: Deprecate...

Issue #3186752 by longwave, ravi.shankar, jonathanshaw, g-brodiei: Deprecate langcode argument to _user_mail_notify()
parent 4823b803
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -259,7 +259,7 @@ public function resetPassword(Request $request) {
      }

      // 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.');
      }
+11 −0
Original line number Diff line number Diff line
@@ -94,4 +94,15 @@ public function testUserMailsNotSent($op) {
    $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());
  }

}
+8 −2
Original line number Diff line number Diff line
@@ -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();