Support » Plugin: iThemes Security (formerly Better WP Security) » Missing site_itsec_bans table caused site crash

  • Resolved ghartwig


    It looks like a new table was added but didn’t get created on our site. Our site was down this morning. I created the table based on the code in core/lib/schema.php and all is well now, but this was a bit dramatic for us today.

    Here is the PHP error from the missing table when errors were turned on (actual site name replaced):

    Fatal error: Uncaught mysqli_sql_exception: Table ‘wordpress_mysite.site_itsec_bans’ doesn’t exist in /var/www/vhosts/ Stack trace: #0 /var/www/vhosts/ mysqli_query() #1 /var/www/vhosts/ wpdb->_do_query() #2 /var/www/vhosts/ wpdb->query() #3 /var/www/vhosts/ wpdb->get_results() #4 /var/www/vhosts/ dbDelta() #5 /var/www/vhosts/ ITSEC_Lib::db_delta_with_error_handling() #6 /var/www/vhosts/ ITSEC_Schema::create_database_tables() #7 /var/www/vhosts/ ITSEC_Lib::create_database_ta in /var/www/vhosts/ on line 2033

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author Timothy Jacobs


    Thanks for the report @ghartwig.

    iThemes Security creates new tables using the WordPress Core function dbDelta. According to that stack trace, the source of that error is when dbDelta looks to see if the table is already installed or not.

    WordPress doesn’t expect the mysql query functions to throw exceptions which isn’t supported by WordPress Core. Instead it checks for errors using mysqli_error. Do you have any references to MYSQLI_REPORT_ERROR in your website? You may need to contact your hosting company.

    Thread Starter ghartwig


    I did find MYSQLI_REPORT_ERROR in my code and have commented it out.

    That must have been it. Thank you for your help!


    Is it safe to say that using mysqli_report() may break dbDelta ?
    And if so, perhaps adding a Note/Feedback to the dbDelta Code Reference page may help others.

    • This reply was modified 4 months, 2 weeks ago by nlpro.

    Can you provide the SQL for installing the missing table?
    Here is the error my site is throwing.

    WordPress database error Table ‘.wp_itsec_bans’ doesn’t exist for query SELECT * FROM wp_itsec_bans WHERE host = ‘’ made by require_once(‘wp-load.php’), require_once(‘wp-config.php’), require_once(‘wp-settings.php’), do_action(‘init’), WP_Hook->do_action, WP_Hook->apply_filters, ITSEC_Lockout->check_for_host_lockouts, ITSEC_Lib::is_ip_banned, iThemesSecurity\Ban_Hosts\Deprecated_Filter_Source->find_ban_for_host, iThemesSecurity\Ban_Hosts\Chain_Source->find_ban_for_host, iThemesSecurity\Ban_Users\Database_Repository->find_ban_for_host

    Plugin Author Timothy Jacobs


    @ghartwig I’m glad you got it working!

    @nlpro Good call. Do you want to submit a note there?

    @lordgoran You can try the following:

    CREATE TABLE wp_itsec_bans (
        host varchar(64) NOT NULL,
        type varchar(20) NOT NULL default 'ip',
        created_at datetime NOT NULL,
        actor_type varchar(20),
        actor_id varchar(128),
        comment varchar(255) NOT NULL default '',
        PRIMARY KEY  (id),
        UNIQUE KEY host (host),
        KEY actor (actor_type,actor_id)                         


    That did the trick!

Viewing 6 replies - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.