diff --git a/core/modules/system/core.api.php b/core/modules/system/core.api.php index 14c894a..c1fe998 100644 --- a/core/modules/system/core.api.php +++ b/core/modules/system/core.api.php @@ -1792,7 +1792,7 @@ function hook_mail($key, &$message, $params) { $context = $params['context']; $variables = array( '%site_name' => \Drupal::config('system.site')->get('name'), - '%username' => user_format_name($account), + '%username' => $account->getUsername(), ); if ($context['hook'] == 'taxonomy') { $entity = $params['entity']; diff --git a/core/modules/user/src/Plugin/EntityReferenceSelection/UserSelection.php b/core/modules/user/src/Plugin/EntityReferenceSelection/UserSelection.php index e2dd03d..ac36673 100644 --- a/core/modules/user/src/Plugin/EntityReferenceSelection/UserSelection.php +++ b/core/modules/user/src/Plugin/EntityReferenceSelection/UserSelection.php @@ -183,6 +183,7 @@ public function entityQueryAlter(SelectInterface $query) { // match the anonymous user, that doesn't actually have a name in the // database. $conditions = &$query->conditions(); + $anonymous_user_name = $this->userStorage->load(0)->getUsername(); foreach ($conditions as $key => $condition) { if ($key !== '#conjunction' && is_string($condition['field']) && $condition['field'] === 'users_field_data.name') { // Remove the condition. @@ -202,7 +203,10 @@ public function entityQueryAlter(SelectInterface $query) { $value_part->condition('anonymous_name', $condition['value'], $condition['operator']); $value_part->compile($this->connection, $query); $or->condition(db_and() - ->where(str_replace('anonymous_name', ':anonymous_name', (string) $value_part), $value_part->arguments() + array(':anonymous_name' => user_format_name($this->userStorage->load(0)))) + ->where( + str_replace('anonymous_name', ':anonymous_name', (string) $value_part), + $value_part->arguments() + array(':anonymous_name' => $anonymous_user_name) + ) ->condition('base_table.uid', 0) ); $query->condition($or);