Do not read config in Drupal\auto_unban\BanIpManager::__construct()

Created on 22 January 2025, 2 months ago

Problem/Motivation

In general, it is discouraged to read config in a service constructor as it might be initialized when that specific config isn't actually needed.

This is especially true for BanIpManager, because it' in the super-critical-path (a middleware), that means it's instantiated even on a page cache it.

The seconds configuration is only needed if an IP is actually being banned.

Steps to reproduce

Proposed resolution

Move the config read into the banIp() method.

Remaining tasks

User interface changes

API changes

Data model changes

πŸ› Bug report
Status

Active

Version

1.0

Component

Code

Created by

πŸ‡¨πŸ‡­Switzerland berdir Switzerland

Live updates comments and jobs are added and updated live.
  • Performance

    It affects performance. It is often combined with the Needs profiling tag.

Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.71.5 2024