Same IP is banned multiple times (conflict with Memcache)

Created on 7 December 2016, about 8 years ago
Updated 22 March 2023, over 1 year ago

When a bot is hitting one of the forbidden paths, the module bans it -- but I get about 50 copies of the banned IP record, rather than one. It appears that each time that IP tries to hit that path, it creates a record in the list of banned IPs, without checking to see if it's already banned.

πŸ› Bug report
Status

Active

Version

1.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States toddwoof

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • πŸ‡¨πŸ‡¦Canada leducdubleuet Chicoutimi QC

    To anyone having this issue nowadays, this is due to the following optional configuration suggested by the memcache module :

    // Don't bootstrap the database when serving pages from the cache.
    $conf['page_cache_without_database'] = TRUE;
    $conf['page_cache_invoke_hooks'] = FALSE;
    

    With these options set as suggested, the Drupal IP blocking does not work at all and that is why the IP is added multiple times since there is no check if it already exists in DB prior to adding.

    We could have a check like this in the function blockUser() :

          if (!db_query("SELECT * FROM {blocked_ips} WHERE ip = :ip", array(':ip' => $ip))->fetchField()) {
            ...
          }
    

    But such a check is not necessary when the blocking actually works!

    Thanks for that great module!

Production build 0.71.5 2024