diff -u b/core/modules/dblog/src/Controller/DbLogController.php b/core/modules/dblog/src/Controller/DbLogController.php --- b/core/modules/dblog/src/Controller/DbLogController.php +++ b/core/modules/dblog/src/Controller/DbLogController.php @@ -15,11 +15,11 @@ use Drupal\Core\Database\Connection; use Drupal\Core\Datetime\DateFormatter; use Drupal\Core\Extension\ModuleHandlerInterface; +use Drupal\Core\Entity\EntityManagerInterface; use Drupal\Core\Form\FormBuilderInterface; use Drupal\Core\Logger\RfcLogLevel; use Drupal\Core\Url; use Symfony\Component\DependencyInjection\ContainerInterface; -use Drupal\user\Entity\User; /** * Returns responses for dblog routes. @@ -55,6 +55,13 @@ protected $formBuilder; /** + * The user storage. + * + * @var \Drupal\user\UserStorageInterface + */ + protected $userStorage; + + /** * {@inheritdoc} */ public static function create(ContainerInterface $container) { @@ -62,7 +69,8 @@ $container->get('database'), $container->get('module_handler'), $container->get('date.formatter'), - $container->get('form_builder') + $container->get('form_builder'), + $container->get('entity.manager') ); } @@ -77,12 +85,15 @@ * The date formatter service. * @param \Drupal\Core\Form\FormBuilderInterface $form_builder * The form builder service. + * @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager + * The entity manager service. */ - public function __construct(Connection $database, ModuleHandlerInterface $module_handler, DateFormatter $date_formatter, FormBuilderInterface $form_builder) { + public function __construct(Connection $database, ModuleHandlerInterface $module_handler, DateFormatter $date_formatter, FormBuilderInterface $form_builder, EntityManagerInterface $entity_manager) { $this->database = $database; $this->moduleHandler = $module_handler; $this->dateFormatter = $date_formatter; $this->formBuilder = $form_builder; + $this->userStorage = $entity_manager->getStorage('user'); } /** @@ -188,7 +199,7 @@ } $username = array( '#theme' => 'username', - '#account' => User::load($dblog->uid), + '#account' => $this->userStorage->load($dblog->uid), ); $rows[] = array( 'data' => array( @@ -239,7 +250,7 @@ $message = $this->formatMessage($dblog); $username = array( '#theme' => 'username', - '#account' => User::load($dblog->uid), + '#account' => $this->userStorage->load($dblog->uid), ); $rows = array( array( diff -u b/core/modules/user/src/Plugin/EntityReferenceSelection/UserSelection.php b/core/modules/user/src/Plugin/EntityReferenceSelection/UserSelection.php --- b/core/modules/user/src/Plugin/EntityReferenceSelection/UserSelection.php +++ b/core/modules/user/src/Plugin/EntityReferenceSelection/UserSelection.php @@ -15,7 +15,6 @@ use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Session\AccountInterface; use Symfony\Component\DependencyInjection\ContainerInterface; -use Drupal\user\Entity\User; /** * Provides specific access control for the user entity type. @@ -38,6 +37,13 @@ protected $connection; /** + * The user storage. + * + * @var \Drupal\user\UserStorageInterface + */ + protected $userStorage; + + /** * Constructs a new UserSelection object. * * @param array $configuration @@ -59,6 +65,7 @@ parent::__construct($configuration, $plugin_id, $plugin_definition, $entity_manager, $module_handler, $current_user); $this->connection = $connection; + $this->userStorage = $entity_manager->getStorage('user'); } /** @@ -181,7 +188,7 @@ $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(User::load(0)))) + ->where(str_replace('anonymous_name', ':anonymous_name', (string) $value_part), $value_part->arguments() + array(':anonymous_name' => user_format_name($this->userStorage->load(0)))) ->condition('base_table.uid', 0) ); $query->condition($or); diff -u b/core/modules/views_ui/src/ViewEditForm.php b/core/modules/views_ui/src/ViewEditForm.php --- b/core/modules/views_ui/src/ViewEditForm.php +++ b/core/modules/views_ui/src/ViewEditForm.php @@ -16,6 +16,7 @@ use Drupal\Core\Datetime\DateFormatter; use Drupal\Component\Utility\NestedArray; use Drupal\Component\Utility\String; +use Drupal\Core\Entity\EntityManagerInterface; use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Render\Element; use Drupal\Core\Url; @@ -24,7 +25,6 @@ use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\RequestStack; use Symfony\Component\DependencyInjection\ContainerInterface; -use Drupal\user\Entity\User; /** * Form controller for the Views edit form. @@ -53,6 +53,13 @@ protected $dateFormatter; /** + * The user storage. + * + * @var \Drupal\user\UserStorageInterface + */ + protected $userStorage; + + /** * Constructs a new ViewEditForm object. * * @param \Drupal\user\TempStoreFactory $temp_store_factory @@ -61,11 +68,14 @@ * The request stack object. * @param \Drupal\Core\Datetime\DateFormatter $date_formatter * The date Formatter service. + * @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager + * The entity manager service. */ - public function __construct(TempStoreFactory $temp_store_factory, RequestStack $requestStack, DateFormatter $date_formatter) { + public function __construct(TempStoreFactory $temp_store_factory, RequestStack $requestStack, DateFormatter $date_formatter, EntityManagerInterface $entity_manager) { $this->tempStore = $temp_store_factory->get('views'); $this->requestStack = $requestStack; $this->dateFormatter = $date_formatter; + $this->userStorage = $entity_manager->getStorage('user'); } /** @@ -75,7 +85,8 @@ return new static( $container->get('user.tempstore'), $container->get('request_stack'), - $container->get('date.formatter') + $container->get('date.formatter'), + $container->get('entity.manager') ); } @@ -132,7 +143,7 @@ if ($view->isLocked()) { $username = array( '#theme' => 'username', - '#account' => User::load($view->lock->owner), + '#account' => $this->userStorage->load($view->lock->owner), ); $lock_message_substitutions = array( '!user' => drupal_render($username),