Home Forums WoodMart support forum Layered Navigation causes WC_Query query_vars warning & slow site

Layered Navigation causes WC_Query query_vars warning & slow site

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #701177

    autopolishing7
    Participant

    Hello,

    I am experiencing a critical performance issue related to WoodMart Layered Navigation widgets on WooCommerce product archive pages.

    Environment
    WordPress: 6.9
    WooCommerce: latest
    Theme: WoodMart 8.3.7
    PHP: 8.3
    WP_DEBUG: enabled
    Server: shared hosting (MySQL max_user_connections limit applies)

    Problem

    The website becomes extremely slow and eventually hits MySQL max_user_connections, causing the site to partially or fully stop responding.

    The debug.log file is continuously filled with the following warning:

    “PHP Warning: Attempt to read property “query_vars” on null
    File: wp-content/plugins/woocommerce/includes/class-wc-query.php
    Lines: 895 / 907″

    This warning is logged many times per single page load.

    Stack trace always includes
    -Automatic\WooCommerce\Internal\ProductAttributesLookup\Filterer
    -WOODMART_Widget_Layered_Nav
    -layered_nav_list
    -dynamic_sidebar
    -archive-product.php

    Observations
    Happens on Shop / product archive pages
    Triggered by WoodMart Layered Navigation widgets
    Attribute counts calculation is involved
    Warning repeats continuously
    debug.log grows very fast
    MySQL connections remain in Sleep state and accumulate
    Eventually MySQL refuses new connections

    Steps to reproduce
    Open the Shop page (e.g. /magazin/) with Layered Navigation widgets enabled
    Reload the page several times or interact with filters
    Check wp-content/debug.log
    The warning appears repeatedly and performance degrades rapidly

    Tests already done
    Disabling Layered Navigation widgets stops the warnings completely
    Issue does not occur when widgets are removed
    Tried custom PHP workaround snippets → caused fatal errors / did not resolve the issue
    The issue appears consistently with WoodMart widgets enabled

    Expected behavior

    Layered Navigation widgets should not trigger repeated WooCommerce query warnings or cause excessive MySQL connections.

    Additional notes

    This seems to be related to how WoodMart handles WooCommerce attribute queries and WC_Query when calculating filtered term counts.

    Please let me know if you need temporary admin access to investigate further.

    Thank you in advance.

    #701217

    autopolishing7
    Participant

    Additional technical details – exact location in WoodMart code

    While debugging the issue, I identified a specific trigger point in the WoodMart code:

    File:
    woodmart/inc/widgets/class-widget-layered-nav.php

    Class:
    WOODMART_Widget_Layered_Nav

    Method:
    get_filtered_term_product_counts( $term_ids, $taxonomy, $query_type )

    Inside this method, WoodMart directly calls WooCommerce’s ProductAttributesLookup Filterer:

    wc_get_container()
    ->get( \Automattic\WooCommerce\Internal\ProductAttributesLookup\Filterer::class )
    ->get_filtered_term_product_counts( $term_ids, $taxonomy, $query_type );

    In my case, this call appears to trigger the WC_Query query_vars warnings and the heavy database queries, leading to CPU and DB spikes on shop and product archive pages.

    Disabling/removing the WoodMart Layered Navigation widgets immediately stops the warnings and the resource usage, which strongly suggests this code path as the source of the issue.

    This information may help you reproduce and debug the problem more quickly.

    #701267

    Artem Temos
    Keymaster

    Hi,

    Thanks for the detailed report. Our Layered Navigation widgets are wrappers over WooCommerce’s native filtering; all filter queries and term counts are performed by WooCommerce. The warnings and DB load you see come from WooCommerce’s Product Attributes Lookup system.

    Please try to compare with default WooCommerce filters. Add the default WooCommerce layered navigation/active filters widgets to the same sidebar and test. They should behave the same as our widgets.

    Kind Regards

Viewing 3 posts - 1 through 3 (of 3 total)