Home Forums WoodMart support forum Database Query Problem (from my host provider)

Database Query Problem (from my host provider)

Viewing 12 posts - 1 through 12 (of 12 total)
  • Author
    Posts
  • #102100

    mark-aaron
    Participant

    Can you please look into why this database query would be causing an issue on my website. My hosting company have checked the database and it looks ok.

    It’s coming from /themes/woodmart/woocommerce/archive-product.php

    They say the query is happening a lot and overcoming my hosting server and making it crasht.

    2019/01/15 16:39:20 [error] 5369#5369: *115336 FastCGI sent in stderr: “PHP message: WordPress database error Not unique table/alias: ‘term_relationships’ for query SELECT COUNT( DISTINCT posts.ID ) as range_count FROM posts
    INNER JOIN term_relationships AS term_relationships ON posts.ID = term_relationships.object_id
    INNER JOIN term_taxonomy AS term_taxonomy USING( term_taxonomy_id )
    INNER JOIN terms AS terms USING( term_id )
    INNER JOIN postmeta ON ( posts.ID = postmeta.post_id )
    LEFT JOIN term_relationships ON (posts.ID = term_relationships.object_id)
    WHERE posts.post_type IN ( ‘product’ )
    AND posts.post_status = ‘publish’
    AND postmeta.meta_key = ‘_price’ AND CAST(postmeta.meta_value AS DECIMAL) BETWEEN ‘0’ AND ‘900’
    AND (
    posts.ID NOT IN (
    SELECT object_id
    FROM term_relationships
    WHERE term_taxonomy_id IN (8)
    )
    AND
    term_relationships.term_taxonomy_id IN (16094)
    )
    made by require(‘wp-blog-header.php’), require_once(‘wp-includes/template-loader.php’), include(‘/plugins/woocommerce/templates/taxonomy-…PHP message: WordPress database error Not unique table/alias: ‘term_relationships’ for query SELECT COUNT( DISTINCT posts.ID ) as range_count FROM posts
    INNER JOIN term_relationships AS term_relationships ON posts.ID = term_relationships.object_id
    INNER JOIN term_taxonomy AS term_taxonomy USING( term_taxonomy_id )
    INNER JOIN terms AS terms USING( term_id )
    INNER JOIN postmeta ON ( posts.ID = postmeta.post_id )
    LEFT JOIN term_relationships ON (posts.ID = term_relationships.object_id)
    WHERE posts.post_type IN ( ‘product’ )
    AND posts.post_status = ‘publish’
    AND postmeta.meta_key = ‘_price’ AND CAST(postmeta.meta_value AS DECIMAL) BETWEEN ‘900’ AND ‘1800’
    AND (
    posts.ID NOT IN (
    SELECT object_id
    FROM term_relationships
    WHERE term_taxonomy_id IN (8)
    )
    AND
    term_relationships.term_taxonomy_id IN (16094)
    )
    made by require(‘wp-blog-header.php’), require_once(‘wp-includes/template-loader.p
    2019/01/15 16:40:24 [error] 5369#5369: *115460 recv() failed (104: Connection reset by peer) while reading response header from upstream, client: 95.108.181.84, server: http://www.hushhush.com, request: “GET /lv/shop/traditionnelle-14-day-tourbillon-openworked-89010-000p-9935-platinum-watch/ HTTP/1.0”, upstream: “fastcgi://unix:/var/run/php7.3-fpm-hushhush.sock:”, host: “www.hushhush.com”

    #102113

    mark-aaron
    Participant

    In the past 12 hours, there’s been 7,425 instances of that error showing up in the log. So it’s quite frequent.

    As far as the effect, it’s causing some portions of the site to return a 500 error code, which prevents php from executing properly.

    #102141

    Artem Temos
    Keymaster

    Hello,

    Could you please check how it works with some default WordPress theme like twentysixteen to understand is it our theme issue or not? It seems to be happening on the shop page. When you will switch to the default theme, you need to add the same widgets to the sidebar to test it. The fact is that our theme doesn’t have any SQL queries at all. All of them come with WooCommerce plugin and WoodMart doesn’t influence it.

    Regards

    #102158

    mark-aaron
    Participant

    If I switch themes will I loose all my current woodmart styling and customisation?

    #102185

    Artem Temos
    Keymaster

    Hello,

    The problem may occur when you switch between themes in Appearance -> Themes is that widgets may lose their positions. It is a WordPress behavior and we are not able to fix this in our theme scope. Now, you need to go to Appearance -> Widgets and move all widgets to appropriate positions.
    As a workaround, you can backup your widgets configurations using this plugin https://wordpress.org/plugins/widget-importer-exporter/

    Regards

    #102347

    mark-aaron
    Participant

    We have found that the query in question is on line 267 of woodmart/inc/widgets/class-widget-price-filter.php

    $query[‘join’] = ”
    INNER JOIN {$wpdb->term_relationships} AS term_relationships ON {$wpdb->posts}.ID = term_relationships.object_id
    INNER JOIN {$wpdb->term_taxonomy} AS term_taxonomy USING( term_taxonomy_id )
    INNER JOIN {$wpdb->terms} AS terms USING( term_id )
    INNER JOIN {$wpdb->postmeta} ON ( {$wpdb->posts}.ID = {$wpdb->postmeta}.post_id )
    ” . $tax_query_sql[‘join’];

    Take a look here at similar probelms by other users https://wordpress.stackexchange.com/questions/283334/wordpress-database-error-not-unique-table-alias-wp-postmeta

    Do you think that query needs to be re-written or if it can be safely commented out?

    #102376

    Artem Temos
    Keymaster

    Try to add the following PHP code snippet to the child theme functions.php file to disable it

    add_filter( 'woodmart_check_ranges_price_filter', '__return_false', 10 );

    #102380

    mark-aaron
    Participant

    Getting this error today (this is before I have edited the above as you have suggested)

    PHP Fatal error: Uncaught Error: Call to undefined function woodmart_is_woo_ajax() in /www/hushhush_328/public/wp-content/themes/woodmart/index.php:6

    #102381

    mark-aaron
    Participant

    Could you tell me where exactly I should add this:

    Try to add the following PHP code snippet to the child theme functions.php file to disable it

    add_filter( ‘woodmart_check_ranges_price_filter’, ‘__return_false’, 10 );

    #102449

    Artem Temos
    Keymaster

    Add it to the end of the functions.php file in your child theme.

    #102610

    mark-aaron
    Participant

    Where can I locate and edit this please?

    #102630

    Artem Temos
    Keymaster

    You can find this file in the folder wp-content/themes/woodmart-child/. If you didn’t install the child theme yet, you can find it in the archive downloaded from ThemeForest. Install and activate it via Appearance -> Themes. https://www.youtube.com/watch?v=q4tU5TAZtIk

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