Problem/Motivation

I was testing the "Enforce auto logout on admin pages" feature in #3579880: Improve documentation for Enforce auto logout on admin pages setting, and used the "Automated logout info" block:

For easier debugging, I added the "Automated logout info" block to both the regular, as well as the admin theme. Under administration ("back end") pages such as /admin/config/people as well as /node/add/page and see this message

Automated logout info
Autologout does not apply on the current page, you will be kept logged in whilst this page remains open.

If I add the "Automated logout info" block, and then enable "Enforce auto logout on admin pages" under /admin/config/people/autologout and save the page, the text in the block remains unchanged.

I need to rebuild caches, for the block text to reflect the actual settings:

Automated logout info
You will be logged out in 1 min if this page is not refreshed before then.

Steps to reproduce

  1. Enable the "Automated logout info" block
  2. Enable "Enforce auto logout on admin pages" (/admin/config/people/autologout), but see the same text in the block
  3. Rebuild caches, and see the actual settings

Proposed resolution

Could rebuilding the caches be added as a last step, after saving configuration via the settings page?

Remaining tasks

User interface changes

API changes

Data model changes

Issue fork autologout-3580475

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

ressa created an issue. See original summary.

ressa’s picture

Issue summary: View changes

deaom made their first commit to this issue’s fork.

deaom’s picture

Status: Active » Needs work
Issue tags: +Needs tests

Added an autologout settings cache to the warning block so the cache gets invalidated after the settings are saved. As it needs a test, setting status to needs works.

ressa’s picture

Wow, that was fast, thanks @deaom 🚀

I can confirm that the code works perfectly, and the text is updated immediately, after clicking "Save configuration", so that bit is solved.

deaom’s picture

Status: Needs work » Needs review
Issue tags: -Needs tests

Test is added so this is now ready for review.

ressa’s picture

Status: Needs review » Reviewed & tested by the community

Beautiful work @deaom, the test will catch an uncached AutologoutWarningBlock block, so the test currently passes as expected, as can be seen in the MR's "testAutologoutWarningBlock" test:

https://git.drupalcode.org/issue/autologout-3580475/-/pipelines/774814/t...

If I comment out the five new lines in src/Plugin/Block/AutologoutWarningBlock.php (which adds the config:autologout.settings cache tag) and run the test, it fails as expected, catching the regression.

the_g_bomb’s picture

Added a couple of typo fix suggestions, but other than that I am good with this.

ressa’s picture

Status: Reviewed & tested by the community » Needs work
ressa’s picture

Status: Needs work » Needs review

Thanks for catching those typos @the_g_bomb, I have applied your suggestions.

ericgsmith’s picture

Status: Needs review » Reviewed & tested by the community

Fixes the issue - suggestions applied so this looks back to RTBC

the_g_bomb’s picture

Issue tags: +DevDaysAthens2026

Merged.

I will consider a follow-up to override the getCacheTags() method on the block class, which would cover all return paths, instead of just the final return path in build().

I am wondering if the return [] path (when preventJs() is true) will not carry the tag, meaning a settings change that affects preventJs()'s return value wouldn't invalidate that cached empty result.

the_g_bomb’s picture

Status: Reviewed & tested by the community » Fixed

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.

ressa’s picture

Very nice, thank you all for fixing this so quickly! It's really nice to see the number of open issues steadily dropping.

Status: Fixed » Closed (fixed)

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