diff --git a/core/modules/user/user.module b/core/modules/user/user.module index 850b894..3991636 100644 --- a/core/modules/user/user.module +++ b/core/modules/user/user.module @@ -8,7 +8,6 @@ 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; @@ -1055,7 +1054,8 @@ 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')) { - UserController::create(Drupal::getContainer())->logout()->send(); + module_load_include('pages.inc', 'user', 'user'); + user_logout(); } if (user_is_anonymous()) { diff --git a/core/modules/user/user.pages.inc b/core/modules/user/user.pages.inc index debb55a..13e613b 100644 --- a/core/modules/user/user.pages.inc +++ b/core/modules/user/user.pages.inc @@ -163,6 +163,22 @@ function user_pass_reset($form, &$form_state, $uid, $timestamp, $hashed_pass, $a } /** + * Logs the current user out, and redirects to the home page. + */ +function user_logout() { + global $user; + + watchdog('user', 'Session closed for %name.', array('%name' => $user->name)); + + module_invoke_all('user_logout', $user); + + // Destroy the current session, and reset $user to the anonymous user. + session_destroy(); + + drupal_goto(); +} + +/** * Process variables for user.tpl.php. * * The $variables array contains the following arguments: