diff --git a/core/modules/user/user.module b/core/modules/user/user.module index da9b1e9..850b894 100644 --- a/core/modules/user/user.module +++ b/core/modules/user/user.module @@ -8,6 +8,7 @@ use Drupal\file\Plugin\Core\Entity\File; use Drupal\user\Plugin\Core\Entity\User; use Drupal\user\UserRole; +use Drupal\user\Controller\UserController; use Drupal\Core\Template\Attribute; use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; use Drupal\menu_link\Plugin\Core\Entity\MenuLink; @@ -1054,8 +1055,7 @@ function user_menu_site_status_alter(&$menu_site_status, $path) { if ($menu_site_status == MENU_SITE_OFFLINE) { // If the site is offline, log out unprivileged users. if (user_is_logged_in() && !user_access('access site in maintenance mode')) { - // Destroy the current session, and reset $user to the anonymous user. - session_destroy(); + UserController::create(Drupal::getContainer())->logout()->send(); } if (user_is_anonymous()) {