Unban link in the Drupal log does not work

Created on 5 August 2023, 11 months ago
Updated 22 October 2023, 8 months ago

Problem/Motivation

The unban button in the Drupal log does not work.

Steps to reproduce

1) Open the Drupal log
2) Ban and IP
3) Try to unban the same IP

Clicking on the unban button does not unban de IP address.

The following error can be found in the Drupal log.

Drupal\Core\Database\DatabaseExceptionWrapper: SQLSTATE[42S02]: Base table or view not found: 1146 Table 'komorebi_v2.bam_ip' doesn't exist: SELECT 1 AS "expression" FROM "bam_ip" "bam_ip" WHERE "ip" = :db_condition_placeholder_0; Array ( [:db_condition_placeholder_0] => 40.83.2.67 ) in Drupal\auto_unban\BanIpManager->unbanIp() (line 100 of /var/www/komorebi-amado.jp/web/modules/contrib/auto_unban/src/BanIpManager.php).

Proposed resolution

From the above error message, it is clear that BanIpManager.php has a typo in the code of the function below that triggers this problem.

  /**
   * {@inheritdoc}
   */
  public function unbanIp($ip) {
    // To unban an IP, set the expires to 0. This is only used by the UI,
    // because IPs are auto-unbanned when the ban expires.
    $this->connection->merge('bam_ip')
      ->key(['ip' => $ip])
      ->fields(['expires' => 0])
      ->execute();
  }

The line

$this->connection->merge('bam_ip')

should be changed to

$this->connection->merge('ban_ip')

After making this change, unban works as expected and no error is found in the Drupal log.

πŸ› Bug report
Status

Fixed

Version

1.0

Component

Code

Created by

πŸ‡―πŸ‡΅Japan jorgemare

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

Comments & Activities

Production build 0.69.0 2024