• Resolved alx359

    (@alx359)


    Have installed Query Monitor, and during WP-Optimize de/activation the following error happens:

    Uncaught mysqli_sql_exception: Table '.wp_wpo_404_detector' doesn't exist
    in /wp-includes/class-wpdb.php on line 2357

    Call stack:

    mysqli_query()
    wp-includes/class-wpdb.php:2357
    wpdb::_do_query()
    wp-includes/class-wpdb.php:2271
    wpdb::query()
    wp-includes/class-wpdb.php:3156
    wpdb::get_results()
    wp-admin/includes/upgrade.php:2998
    dbDelta()
    wp-content/plugins/wp-optimize/includes/class-wp-optimize-table-management.php:54
    WP_Optimize_Table_Management::create_plugin_tables()
    wp-content/plugins/wp-optimize/includes/class-wpo-activation.php:32
    WPO_Activation::actions()
    wp-includes/class-wp-hook.php:341
    WP_Hook::apply_filters()
    wp-includes/class-wp-hook.php:365
    WP_Hook::do_action()
    wp-includes/plugin.php:522
    do_action()
    wp-admin/includes/plugin.php:703
    activate_plugin()
    wp-admin/plugins.php:60

    The error appears during this prepared sql statement that dbDelta() doesn’t seem to like:

    CREATE TABLE wp_wpo_404_detector (
    ID int(11) UNSIGNED NOT NULL auto_increment,
    url TEXT NOT NULL,
    request_timestamp BIGINT UNSIGNED NOT NULL,
    request_count BIGINT UNSIGNED NOT NULL,
    referrer TEXT NOT NULL,
    PRIMARY KEY (ID),
    KEY url_timestamp_referrer (url(75),request_timestamp,referrer(75)),
    KEY timestamp_count (request_timestamp,request_count),
    UNIQUE (url(75),request_timestamp,referrer(75))
    )

    GPT suggested this change:

    CREATE TABLE wp_wpo_404_detector (
    ID int(11) UNSIGNED NOT NULL auto_increment,
    url VARCHAR(255) NOT NULL,
    request_timestamp BIGINT UNSIGNED NOT NULL,
    request_count BIGINT UNSIGNED NOT NULL,
    referrer VARCHAR(255) NOT NULL,
    PRIMARY KEY (ID),
    KEY url_timestamp_referrer (url, request_timestamp, referrer),
    KEY timestamp_count (request_timestamp, request_count),
    UNIQUE KEY unique_url_ts_ref (url, request_timestamp, referrer)
    )
Viewing 9 replies - 1 through 9 (of 9 total)
  • Plugin Support jbgupdraft

    (@jbgupdraft)

    Hi,

    Thanks for reaching out about this! I have seen a few of these cases but normally a deactivation and reactivation of the plugin fixes it. I’m guessing that didn’t work in your case?

    I’d like to see if I can reproduce this on some of my test sites but want to check some details to make sure I can make my environment similar to yours.

    Could you let me know which web server type this site is running on (Apache, Nginx, Litespeed) as well as the version of PHP and the version of the database server and if it’s running MySQL or Mariadb? I also want to confirm the version of WordPress and WP-Optimize that you’re running.

    Also, was this on a fresh installation of WP-Optimize or has the plugin been installed for a while?

    Thank you!

    Thread Starter alx359

    (@alx359)

    Hi @jbgupdraft thanks for replying.

    You’re right. Tried in another env (localwp Win10//mariadb10.4|10.6//php8.3|8.4) and wpo de/activated fine with QM.

    The env that gives me issues is a VPS with Ubuntu 24.04.3, latest HestiaCP (Nginx+Apache), WP 6.9, 11.4.9-MariaDB, and php8.3-fpm. WPO fresh from the WP repository.

    HTH. If req other assistance let me know.

    Plugin Support jbgupdraft

    (@jbgupdraft)

    Hi,

    Thanks for the details! I will spin up a new VM and install HestiaCP to see if I can reproduce the same error as you.

    I’ll keep you posted!

    Plugin Support jbgupdraft

    (@jbgupdraft)

    Hi,

    Thanks for your patience! Unfortunately with a fresh install of WP and Hestia with the same PHP and MariaDB and Ubuntu version as you I was unable to reproduce the issue with the table not being created. I have reached out to our development team about this though as I do see this issue come up intermittently.

    One thing I’m wondering if you could try on your side, would it be possible to do a plugin conflict test to see if something else might be interfering with the table creation?

    Thank you!

    Thread Starter alx359

    (@alx359)

    @jbgupdraft, understood. Tried switching off all other plugins, theme to default. Only updraft and qm enabled, Still got the issue. Not sure what else could try.

    Added an error_log statement before dbDelta($create_table) to produce the sql on the first post. If you may want me to install a debug version of updraft to produce more useful logs could do that to.

    Plugin Support jbgupdraft

    (@jbgupdraft)

    Hi,

    thanks for the update! One thing we can do is I can just send you the SQL query to run if you have access to PHPMyAdmin, I believe I tested the one that you included in your initial message and it worked when running it with PHPMyAdmin but I can double check and let you know.

    I have also reached out to our developers about this and they’re looking into a similar issue and working on a fix. One quick question, has this site always been using the Free version of WP-Optimize or was the Premium version installed at any point?

    Thank you!

    Thread Starter alx359

    (@alx359)

    No problem. May send at gmail where user is the same as my handle here.

    The explanation given by GPT sounded plausible though. The issue isn’t the validity of the SQL statement per se, but some inherent limitations of dbDelta(). For example, IF NOT EXISTS that breaks other plugins under QM but gets masked in normal circumstances.

    Thread Starter alx359

    (@alx359)

    Found the culprit. The issue was indeed my fault. There was a redundant wp-content\db.php remaining from another plugin I was testing that was being picked up by WP and creating unexpected havoc. Sincerest apologies for the wasted time!

    Plugin Support jbgupdraft

    (@jbgupdraft)

    Great find!

    I’m glad to hear you were able to track down the issue, and I’ll add this solution to my toolkit for things to check in the future!

Viewing 9 replies - 1 through 9 (of 9 total)

You must be logged in to reply to this topic.