• Resolved ghartwig

    (@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/mysite.com/httpdocs/wp-includes/wp-db.php:2033 Stack trace: #0 /var/www/vhosts/mysite.com/httpdocs/wp-includes/wp-db.php(2033): mysqli_query() #1 /var/www/vhosts/mysite.com/httpdocs/wp-includes/wp-db.php(1922): wpdb->_do_query() #2 /var/www/vhosts/mysite.com/httpdocs/wp-includes/wp-db.php(2673): wpdb->query() #3 /var/www/vhosts/mysite.com/httpdocs/wp-admin/includes/upgrade.php(2703): wpdb->get_results() #4 /var/www/vhosts/mysite.com/httpdocs/wp-content/plugins/better-wp-security/core/lib.php(2161): dbDelta() #5 /var/www/vhosts/mysite.com/httpdocs/wp-content/plugins/better-wp-security/core/lib/schema.php(177): ITSEC_Lib::db_delta_with_error_handling() #6 /var/www/vhosts/mysite.com/httpdocs/wp-content/plugins/better-wp-security/core/lib.php(62): ITSEC_Schema::create_database_tables() #7 /var/www/vhosts/mysite.com/httpdocs/wp-content/plugins/better-wp-security/core/setup.php(81): ITSEC_Lib::create_database_ta in /var/www/vhosts/mysite.com/httpdocs/wp-includes/wp-db.php on line 2033

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

    (@timothyblynjacobs)

    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.

    https://github.com/WordPress/wordpress-develop/blob/2d12c86d823e2466073c9a38df0d99f8dcc73e63/src/wp-admin/includes/upgrade.php#L2703

    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

    (@ghartwig)

    I did find MYSQLI_REPORT_ERROR in my code and have commented it out.
    mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT);

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

    @timothyblynjacobs

    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 years, 1 month 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 = ‘108.84.194.62’ 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

    (@timothyblynjacobs)

    @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 (
        id bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT,
        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)                         
    )

    Thanks!

    That did the trick!

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Missing site_itsec_bans table caused site crash’ is closed to new replies.