- Issue created by @capysara
- πΊπΈUnited States lisagodare@gmail.com
I believe the intent is to use `hook_autologout_prevent` for that. Specifically, the module does implement that hook, and if the user timeout is set to 0, it is deleting the relevant session variable.
// If user has no timeout set. if (\Drupal::service('autologout.manager')->getUserTimeout() === 0) { autologout_check_session_variable(); return TRUE; }
/** * Helper function to unset the autologout session variable if present. */ function autologout_check_session_variable() { $currentRequest = \Drupal::service('request_stack')->getCurrentRequest(); $session = $currentRequest->getSession()->get('autologout_last'); if (isset($session)) { $currentRequest->getSession()->remove('autologout_last'); } }
So in the code you're looking at: `$session` should be null (and PHP will likely convert it to 0 when doing math), `$now` will be some horrifically large number (e.g., 1718311268), and `$diff` will be equal to $now.
A quick fix might be to implement the hook yourself, and if the user timeout is 0, set the session variable to some unreasonably high number, like "$now + $padding + 1". You'll likely want to make sure your hook implementation runs last as well.
/** * Implements hook_autologout_prevent(). */ function mymodule_autologout_prevent() { $manager = \Drupal::service('autologout.manager'); // If user has no timeout set. if ($manager->getUserTimeout() === 0) { $now = \Drupal::time()->getCurrentTime(); $padding = \Drupal::config('autologout.settings')->get('padding'); $currentRequest = \Drupal::service('request_stack')->getCurrentRequest(); $currentRequest->getSession()->('autologout_last', $now+$padding+1); return TRUE; } }