Problem/Motivation

After the user logs out, the JS autologoutGetTimeLeft() function is being called multiple times, generating an excessive amount of logs in the database log (dblog), which is significantly increasing the size of the dblog table when you have lots of users.

Steps to reproduce

1. Set the automatic logout timeout to 1 minute;
2. Clear the Drupal cache;
3. Log in and wait wait until you are automatically logged out by the autologout module;
5. Check the dblog (See the attached image).

Expected Behavior

We expect that the autologoutGetTimeLeft function will not be called multiple times if the user is already logged out, in order to avoid "access denied" logs.

Proposed resolution

I suggest adding the following code to the autologoutGetTimeLeft function in JavaScript. This modification worked for me:

js/autologout.hs

Drupal.Ajax.prototype.autologoutGetTimeLeft = function (callback) {
  let ajax = this;

  // If an AJAX request is currently running, don't run this one.
  // This prevents multiple AJAX requests from running at the same time.
  if (ajax.ajaxing) {
    return false;
  }

  // If there is no user, don't make an AJAX request and just redirect.
  if (typeof drupalSettings.user === 'undefined') {
    return false;
   }

  (...)
CommentFileSizeAuthor
#6 autologout_3576757.patch874 bytesedsoncarlos
autologout.png166.34 KBedsoncarlos

Issue fork autologout-3576757

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

edsoncarlos created an issue. See original summary.

edsoncarlos’s picture

Title: Excessive Logging in autologoutGetTimeLeft Function After User Logout » Excessive "Access denied" logs from Ajax during automatic user logout.
edsoncarlos’s picture

Issue summary: View changes
edsoncarlos’s picture

Issue summary: View changes
edsoncarlos’s picture

StatusFileSize
new874 bytes

A patch with the proposed solution.

the_g_bomb’s picture

Status: Active » Needs review

I suspect this will have been fixed in the recent round of improvements, please retest

the_g_bomb’s picture

Status: Needs review » Postponed
the_g_bomb’s picture

Status: Postponed » Closed (cannot reproduce)

I have tested this with the latest dev branch and suspect the other work done has solved this. Please feel free to reopen and update the steps to reproduce if you are still having problems.

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

the_g_bomb’s picture

Status: Closed (cannot reproduce) » Fixed

Changing status to represent the actual status

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.