Table 'flood' is not found

Created on 7 January 2025, 3 months ago

Problem/Motivation

Drupal core creates table 'flood' only when trying to first write to it or check if user is allowed to login.

Steps to reproduce

  1. Install site
  2. Install flood_control module
  3. Navigate to /admin/people/flood-unblock page

Proposed resolution

Check in src/FloodUnblockManagerDatabase.php method getEntries that table flood exists before querying the database

🐛 Bug report
Status

Active

Version

3.0

Component

Code

Created by

🇩🇪Germany a.dmitriiev

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

Merge Requests

Comments & Activities

  • Issue created by @a.dmitriiev
  • Pipeline finished with Success
    3 months ago
    Total: 171s
    #389709
  • Hi @a.dmitriiev,

    I have reproduced the issue by deleting the flood table and visiting the /admin/people/flood-unblock page, which resulted in the error:
    The website encountered an unexpected error. Try again later.

    To address this, I’ve added a validation to check whether the flood table exists:

    If the table exists : The functionality works as expected.
    If the table does not exist :

    • A logger error is recorded: "The flood table does not exist."
    • The /admin/people/flood-unblock page displays the message: "There is no table found named flood."

    I’ve attached screenshots showing the behavior before and after implementing the changes for your reference.

    Please let me know if any additional changes are needed, such as:

    • Displaying an error message at the top of the page.
    • Adjusting the wording of the message.

    Thank you !

  • 🇩🇪Germany a.dmitriiev

    There are also other public methods in src/FloodUnblockManagerDatabase.php class that query the same flood table. I think they also need this check.

  • I'll check for the rest of the public methods too.

  • Hi @a.dmitriiev,

    I have reviewed the additional public methods in the src/FloodUnblockManagerDatabase.php class that query the flood table and added the necessary validation to check whether the flood table exists. Here are the changes made:

    1. Added a floodTableExists() check in all relevant public methods of the FloodUnblockManagerDatabase class:

    • floodUnblockClearEvent: Ensures the table exists before attempting to clear flood entries.
    • getEntries: Returns an empty array if the table does not exist.
    • getEventIds: Returns an empty array if the table does not exist.

    2. Updated the Drush commands in FloodUnblockCommands to handle cases where getEventIds or floodUnblockClearEvent might not proceed due to the missing table.

    Please let me know if any additional adjustments are needed. Thank you !

  • Pipeline finished with Success
    3 months ago
    Total: 302s
    #390440
  • 🇻🇳Vietnam thaoquang

    I got same error

    Drupal\Core\Database\DatabaseExceptionWrapper: SQLSTATE[42S02]: Base table or view not found: 1146 Table 'db_hoathi.le_flood' doesn't exist: SELECT COUNT(*) AS "expression" FROM (SELECT 1 AS "expression" FROM "le_flood" "f") "subquery"; Array ( ) in Drupal\flood_control\FloodUnblockManagerDatabase->getEntries() (line 134 of /d11/modules/contrib/flood_control/src/FloodUnblockManagerDatabase.php).
    
  • 🇮🇳India kalash-j jaipur

    Hi @anish.ir,

    Thanks for the updates! I have tested MR !54, and it is working as expected. The validation correctly prevents queries when the flood table is missing, ensuring better error handling. All instances of database queries on the flood table are properly wrapped with the existence check!

  • 🇺🇸United States ahmadhalah

    I'm getting the same error

  • 🇳🇱Netherlands batigolix Utrecht
  • 🇳🇱Netherlands batigolix Utrecht
  • Pipeline finished with Skipped
    about 1 month ago
    #436413
  • 🇳🇱Netherlands batigolix Utrecht

    Thanks for the help with this one.

  • Status changed to Fixed 26 days ago
  • Automatically closed - issue fixed for 2 weeks with no activity.

Production build 0.71.5 2024