I think the code inside simpleautologout_page_attachments() is only necessary for logged in users (as anonymous users cannot be logged out). Checking if the user is logged-in before running this code would boost performance.

Is there a reason this needs to run for anonymous users as well? Please can you try and explain it to me.

Comments

scambler created an issue. See original summary.

noorulshameera’s picture

Status: Active » Needs review
StatusFileSize
new3.6 KB

Adding patch to make code inside simpleautologout_page_attachments() should work only for authenticated user

scambler’s picture

Thank you @noorulshameera

I am also wondering if there is any use using PrivateTempStore? From what I can see, the session time is set and then immediately called again in the next line. I have recently had a client's site go down because the tempstore was locked, causing an exception on every page.

This:

  $service = \Drupal::service('tempstore.private')->get('simpleautologout');
  $service->set('simpleautologout_session_time', time());

  $simpleautologout_session_time = $service->get('simpleautologout_session_time');

Could simply become:
$simpleautologout_session_time = time();

This would also apply to simpleautologout_user_login()

scambler’s picture

StatusFileSize
new4.08 KB

I have created a combined patch:

abhishek.kumar’s picture

Assigned: Unassigned » abhishek.kumar
StatusFileSize
new4 KB

Patch 4 is giving errot so updated it.

  • abhishek.kumar authored eebdd0bf on 8.x-1.x
    Issue #3327362 by scambler, noorulshameera, abhishek.kumar: Should...
abhishek.kumar’s picture

Status: Needs review » Fixed

Applied patch

abhishek.kumar’s picture

Status: Fixed » Closed (fixed)