• Resolved Michael

    (@michael8888)


    The Query Monitor plugin shows several database syntax errors if you access the WordPress admin interface.

    This is one example:

    Component:
    Plugin: fast-velocity-minify

    Caller:
    fvm_plugin_activate()

    Error message:
    You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘IF’ at line 1

Viewing 9 replies - 1 through 9 (of 9 total)
  • Plugin Author Raul P.

    (@alignak)

    What is the exact query triggering the error?

    It’s likely something specific to your server or some other plugin.
    There were no database changes since version 3.0 so this cannot be new.
    I suggest you disable and enable the plugin and see if it still shows up.

    I am using both plugins and I don’t get any error at all related with FVM, or database.
    The fvm_plugin_activate() is the default routine to install the tables, if missing.

    It also occurs after we check if the table exist and it fails.
    The query is like this SHOW TABLES LIKE '{$wpdb->prefix}fvm_cache'

    If your database user has restrictions and doesn’t allow this type of database query, that may be the reason. I suggest you ask your hosting about that.

    Thread Starter Michael

    (@michael8888)

    Paul, the bug exists since version 3. How could another plugin cause an SQL syntax error in your plugin?

    Did you actually install Query Monitor?

    Turns out that version 3 has quite a few other bugs. It often delivers empty pages in combination W3 Total Cache. We also noticed that version doesn’t really improve speed. With version 2.8 we get a score 80-90 in Google’s PageSpeeds Insights with version 3 we get 45.

    Guess we have to stick with version 2.8 until version 3 is more stable.

    Plugin Author Raul P.

    (@alignak)

    What is the error you see exactly, I asked.

    Yes, there are lots of plugins that intercept mysql queries, including the query monitor plugin and plenty of cache related plugins, meant to speed up queries.

    Yes, I have obviously tested before replying as I always use it.
    Also, no php or mysql errors related to FVM: https://i.imgur.com/FY9Zo5D.png

    So try to disable and enable back the plugin and check.
    Perhaps the database creation routines are failing on your server, for whatever reason.

    Yes, FVM 3 had issues which is why you are seeing a lot of updates to sort them out as they appear and as I add other feature requests. At the moment, no errors known on 3.1.3.

    If you get white pages, likely your server runs out of memory or your configuration is cutting execution times short, due to some conflict with some setting on w3tc.

    FVM 3 will improve your speed, as long as you know how to configure it.
    There are instructions on the HELP tab explaining each setting.

    There are several topics saying the same, which have been sorted by properly adjusting settings.

    Thread Starter Michael

    (@michael8888)

    Trust me, I know how to configure FVM4. I guess we don’t see performance improvements with version 3 because because of the SQL syntax errors.

    I tested now on another server with no other plugins enabled and a WordPress standard theme. Same 4 errors. All similar like this one:

    You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘IF’ at line 1

    Caller is fvm_plugin_activate().

    Make sure to use the Query Monitor plugin and access the WP Admin page.

    Plugin Author Raul P.

    (@alignak)

    I believe you, but as you also saw from my screenshot, there are no errors.

    So that means, either your database user restricts the query, or your mysql configuration prevents it from accepting the query. There are many settings that could prevent certain queries, hence you need to check your mysql logs on the server, which will give you the exact query and why is it failing.

    I need to know the exact query and the error message from the mysql logs.
    Not from query monitor plugin… that is not complete.
    Please ask your hosting for that information.

    Which MySQL and PHP versions are you running?
    Be advised that MySQL 8 may not accept a lot of queries that were working fine on version 5.7 without some rules on my.cnf file… though it should be fine for FVM.

    The fvm_plugin_activate function is pretty standard.
    It’s just creating the table, according to wordpress documentation.
    It’s working on many servers and many sites, no issues at all.

    Here are the 2 queries running:

    View post on imgur.com

    So either, your server doesn’t accept the IF NOT EXISTS rule, or perhaps your $wpdb->collate defined on wp-config.php is not supported by your mysql server.

    Either way, if you can check the mysql log, please let me know.

    You can also try this:
    https://ww.wp.xz.cn/support/article/debugging-in-wordpress/#savequeries

    Thread Starter Michael

    (@michael8888)

    We use MySQL 5.7.32, PHP 7.2.24.

    I don’t see errors in the MySQL error.log.

    I wonder why fvm_plugin_activate() runs whenever I access WP Admin?

    Plugin Author Raul P.

    (@alignak)

    It runs because when it detects you are an admin user, 2 things happen in sequence.

    a) fvm_check_misconfiguration (which will check if the plugin has writing permissions)
    b) fvm_initialize_database (which will check if the tables exist or not, and if not, launch the fvm_plugin_activate)

    The fvm_initialize_database simply checks if the table exists.

    View post on imgur.com

    if failing, calls the fvm_plugin_activate to create the tables.

    What is your $wpdb->prefix ?
    Maybe if it’s weird, that could be the reason.

    Thread Starter Michael

    (@michael8888)

    I wonder why I only see the error on a WP admin page but not on normal page when I am logged in as admin.

    We use the same prefix for the last 15 years or. So I don’t think that this is the reason.

    We stick with the old version for a while. The problem with the empty pages is the bigger problem in the new version. We have several thousand pages and it takes a while until we notice that a page is empty. This is hard to debug because it happens only occasionally. I hope you can fix that.

    Thanks for your help!

    Plugin Author Raul P.

    (@alignak)

    As explained, the database creation routine only fires under those conditions.
    On the frontend, it wouldn’t make sense to check for the tables on every pageview.

    I’ll add some escaping for the prefix name on the next version, just to be sure it wasn’t the prefix.

    Let me know if it works for you, else you would need to debug the query as I explained earlier, to see why it’s failing.

    If the prefix is customized, that is likely the reason, but again, I am also using a custom prefix on several sites, and no issues. I cannot fix what I cannot experience.

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

The topic ‘BUG: Fast Velocity Minify 3.1.1 database syntax error’ is closed to new replies.