Home › Forums › WoodMart support forum › Database Query Problem (from my host provider)
Database Query Problem (from my host provider)
- This topic has 11 replies, 2 voices, and was last updated 5 years, 11 months ago by Artem Temos.
-
AuthorPosts
-
January 15, 2019 at 8:29 pm #102100
mark-aaronParticipantCan 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”January 15, 2019 at 8:43 pm #102113
mark-aaronParticipantIn 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.
January 16, 2019 at 7:06 am #102141
Artem TemosKeymasterHello,
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
January 16, 2019 at 7:55 am #102158
mark-aaronParticipantIf I switch themes will I loose all my current woodmart styling and customisation?
January 16, 2019 at 9:11 am #102185
Artem TemosKeymasterHello,
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
January 16, 2019 at 10:35 pm #102347
mark-aaronParticipantWe 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?
January 17, 2019 at 7:07 am #102376
Artem TemosKeymasterTry 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 );
January 17, 2019 at 7:17 am #102380
mark-aaronParticipantGetting 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
January 17, 2019 at 7:18 am #102381
mark-aaronParticipantCould 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 );
January 17, 2019 at 12:21 pm #102449
Artem TemosKeymasterAdd it to the end of the
functions.php
file in your child theme.January 18, 2019 at 7:08 am #102610
mark-aaronParticipantWhere can I locate and edit this please?
January 18, 2019 at 7:23 am #102630
Artem TemosKeymasterYou 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 -
AuthorPosts
- You must be logged in to create new topics. Login / Register