Closed (outdated)
Project:
Ban
Version:
1.1.x-dev
Component:
Code
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Reporter:
Created:
17 Mar 2026 at 08:22 UTC
Updated:
30 Mar 2026 at 07:31 UTC
Jump to comment: Most recent
Through #3392147: Add an allowed IP list to the Ban module, we are now injecting the config factory in the middleware. This will probably have a high performance impact, since the config factory has a lot of dependencies including the event dispatcher and the module handler.
Only initiate the config manager when needed. We can try fixing it similiar to how it was done in #3551605: Injecting ConfigFactory into BanIpManager is expensive, use a closure
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
Comment #3
grevil commentedNot quite sure, if this provides any benefits, since we always call handle anyway. The closure config factory service only gets initiated once first called, but since we always call handle and the ip is assumably always set, I doubt this brings many benefits, but I might be wrong, since I never used symfony service closures before.
See https://symfony.com/doc/current/service_container/service_closures.html for further informations on the topic.
Comment #4
grevil commentedAlright, please review!
Comment #5
grevil commentedRan into #3579658: Using symfony service closures causes fatal error, while implementing this, but shouldn't be our concern.
Comment #6
mstrelan commentedIt looks good, only one small thing. I think the deprecation message still needs to be in the constructor while the Drupal::service call should stay where it is.
Comment #7
grevil commentedAlright, that should do the trick then!
Comment #8
anybodyEverything addressed. RTBC.
Comment #10
berdir> I doubt this brings many benefits, but I might be wrong, since I never used symfony service closures before.
You're not wrong. This doesn't help. It only helps in auto_unban because config there is only needed when banning an IP, not when checking it.
A partial improvement is to move the allowed list check inside isBanned(), then it's only loaded on if the IP is banned, where performance possibly isn't crucial. Until you get hammered by a bot and then performance and the point if blocking in a middleware in the first place is important again.
See my comments in #3578480: Worth caching allowed IP list in middleware?
Comment #11
anybodyClosing this outdated as we will resolve this in #3582177: Rewrite IP allowlist using a settings.php setting as discussed in #3578480: Worth caching allowed IP list in middleware? and #3582176: Add a performance test
Thank you @berdir!!