Updated Drupal to 8.6. This goes with the following updates because it's possible...
[yaffs-website] / web / core / modules / user / user.module
index cabe189e5a744ba1843cd8031245a866d86b8ea6..053429f4b87f84abaa609ad8d6b6dd1906b64283 100644 (file)
@@ -491,9 +491,9 @@ function template_preprocess_username(&$variables) {
   // unsanitized version, in case other preprocess functions want to implement
   // their own shortening logic or add markup. If they do so, they must ensure
   // that $variables['name'] is safe for printing.
-  $name  = $account->getDisplayName();
+  $name = $account->getDisplayName();
   $variables['name_raw'] = $account->getUsername();
-  if (Unicode::strlen($name) > 20) {
+  if (mb_strlen($name) > 20) {
     $name = Unicode::truncate($name, 15, FALSE, TRUE);
     $variables['truncated'] = TRUE;
   }
@@ -569,7 +569,7 @@ function user_login_finalize(UserInterface $account) {
 /**
  * Implements hook_user_login().
  */
-function user_user_login($account) {
+function user_user_login(UserInterface $account) {
   // Reset static cache of default variables in template_preprocess() to reflect
   // the new user.
   drupal_static_reset('template_preprocess');
@@ -578,7 +578,7 @@ function user_user_login($account) {
 /**
  * Implements hook_user_logout().
  */
-function user_user_logout($account) {
+function user_user_logout(AccountInterface $account) {
   // Reset static cache of default variables in template_preprocess() to reflect
   // the new user.
   drupal_static_reset('template_preprocess');
@@ -609,7 +609,7 @@ function user_pass_reset_url($account, $options = []) {
     ],
     [
       'absolute' => TRUE,
-      'language' => \Drupal::languageManager()->getLanguage($langcode)
+      'language' => \Drupal::languageManager()->getLanguage($langcode),
     ]
   );
 }
@@ -638,7 +638,7 @@ function user_cancel_url(UserInterface $account, $options = []) {
   return \Drupal::url('user.cancel_confirm', [
     'user' => $account->id(),
     'timestamp' => $timestamp,
-    'hashed_pass' => user_pass_rehash($account, $timestamp)
+    'hashed_pass' => user_pass_rehash($account, $timestamp),
   ], $url_options);
 }
 
@@ -690,7 +690,7 @@ function user_cancel($edit, $uid, $method) {
   $account = User::load($uid);
 
   if (!$account) {
-    drupal_set_message(t('The user account %id does not exist.', ['%id' => $uid]), 'error');
+    \Drupal::messenger()->addError(t('The user account %id does not exist.', ['%id' => $uid]));
     \Drupal::logger('user')->error('Attempted to cancel non-existing user account: %id.', ['%id' => $uid]);
     return;
   }
@@ -761,7 +761,7 @@ function _user_cancel($edit, $account, $method) {
       }
       $account->block();
       $account->save();
-      drupal_set_message(t('%name has been disabled.', ['%name' => $account->getDisplayName()]));
+      \Drupal::messenger()->addStatus(t('%name has been disabled.', ['%name' => $account->getDisplayName()]));
       $logger->notice('Blocked user: %name %email.', ['%name' => $account->getAccountName(), '%email' => '<' . $account->getEmail() . '>']);
       break;
 
@@ -772,7 +772,7 @@ function _user_cancel($edit, $account, $method) {
         _user_mail_notify('status_canceled', $account);
       }
       $account->delete();
-      drupal_set_message(t('%name has been deleted.', ['%name' => $account->getDisplayName()]));
+      \Drupal::messenger()->addStatus(t('%name has been deleted.', ['%name' => $account->getDisplayName()]));
       $logger->notice('Deleted user: %name %email.', ['%name' => $account->getAccountName(), '%email' => '<' . $account->getEmail() . '>']);
       break;
   }
@@ -900,7 +900,7 @@ function user_delete_multiple(array $uids) {
  *   content language of the current request.
  *
  * @return array
- *   An array as expected by drupal_render().
+ *   An array as expected by \Drupal\Core\Render\RendererInterface::render().
  */
 function user_view($account, $view_mode = 'full', $langcode = NULL) {
   return entity_view($account, $view_mode, $langcode);
@@ -918,7 +918,8 @@ function user_view($account, $view_mode = 'full', $langcode = NULL) {
  *   content language of the current request.
  *
  * @return array
- *   An array in the format expected by drupal_render().
+ *   An array in the format expected by
+ *   \Drupal\Core\Render\RendererInterface::render().
  */
 function user_view_multiple($accounts, $view_mode = 'full', $langcode = NULL) {
   return entity_view_multiple($accounts, $view_mode, $langcode);