• Resolved JapeNZ

    (@japenz)


    Hi there,

    I’m seeing the following issue in my debug log and the CPU usage for my site is very high.

    [25-Jan-2026 03:43:27 UTC] WordPress database error 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 ‘THEN 2 ELSE 6 END), wp_posts.post_date DESC LIMIT 0, 50’ at line 11 for query SELECT SQL_CALC_FOUND_ROWS wp_posts.ID FROM wp_posts WHERE 1=1 AND ( wp_posts.ID NOT IN ( SELECT object_id FROM wp_term_relationships WHERE term_taxonomy_id IN (2622,2625) ) ) AND (((wp_posts.post_title NOT LIKE ‘%flex%’) AND (wp_posts.post_excerpt NOT LIKE ‘%flex%’) AND (wp_posts.post_content NOT LIKE ‘%flex%’))) AND (wp_posts.post_password = ”) AND ((wp_posts.post_type = ‘product’ AND (wp_posts.post_status = ‘publish’))) GROUP BY wp_posts.ID ORDER BY (CASE WHEN THEN 2 ELSE 6 END), wp_posts.post_date DESC LIMIT 0, 50 made by require(‘wp-blog-header.php’), wp, WP->main, WP->query_posts, WP_Query->query, WP_Query->get_posts
    [25-Jan-2026 03:43:28 UTC] WordPress database error 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 ‘THEN 2 ELSE 6 END), wp_posts.post_date DESC’ at line 11 for query SELECT wp_posts.ID FROM wp_posts WHERE 1=1 AND ( wp_posts.ID NOT IN ( SELECT object_id FROM wp_term_relationships WHERE term_taxonomy_id IN (2622,2625) ) ) AND (((wp_posts.post_title NOT LIKE ‘%flex%’) AND (wp_posts.post_excerpt NOT LIKE ‘%flex%’) AND (wp_posts.post_content NOT LIKE ‘%flex%’))) AND (wp_posts.post_password = ”) AND wp_posts.post_type = ‘product’ AND ((wp_posts.post_status = ‘publish’)) GROUP BY wp_posts.ID ORDER BY (CASE WHEN THEN 2 ELSE 6 END), wp_posts.post_date DESC made by require(‘wp-blog-header.php’), require_once(‘wp-includes/template-loader.php’), do_action(‘template_redirect’), WP_Hook->do_action, WP_Hook->apply_filters, FilterEverything\Filter\Plugin->prepareEntities, FilterEverything\Filter\EntityManager->prepareEntitiesToDisplay, FilterEverything\Filter\EntityManager->getAllSetWpQueriedPostIds, WP_Query->get_posts

    According to to a search on phpmyadmin the ‘WHERE term_taxonomy_id IN (2622,2625)’ that seems to cause the issue in both errors refers to:

    2603 exclude-from-search product_visibility 2622
    2606 outofstock product_visibility 2625

    Do I have a setting wrong?
    Please let me know how I can fix this issue as it’s currently causing major issues due to CPU usage.

    Thank you for your help!

Viewing 1 replies (of 1 total)
  • Plugin Support fesupportteam

    (@fesupportteam)

    Hi @japenz

    We have checked the provided query, and the issue is caused by this part:

    ORDER BY (CASE WHEN THEN 2 ELSE 6 END)

    The issue is that the CASE WHEN clause is missing the condition after WHEN, which is why it is causing an error.

    However, in our plugin, filtering queries do not use and have never used CASE WHEN parameters. So either the query is being modified by separate custom code, or it was modified directly in the plugin.

    Please try turning off all custom code, using the default 2025 theme, clean plugin, and deactivate all other plugins to check if the query changes and no longer contains the CASE WHEN parameter.

    Best Regards,
    Victor

Viewing 1 replies (of 1 total)

You must be logged in to reply to this topic.