Support » Plugin: Advanced AJAX Product Filters » WordPress database error

  • Resolved fkoomek

    (@fkoomek)


    Hello.
    Wouldn’t you know what could cause this error?

    [01-May-2019 16:04:33 UTC] WordPress database error Table ‘database_name.wp_posts’ doesn’t exist for query
    SELECT filtered_post.id, filtered_post.out_of_stock, COUNT(filtered_post.ID) as post_count FROM
    (
    SELECT filtered_post.*, max_filtered_post.max_meta_count, stock_table.out_of_stock_init as out_of_stock FROM
    (
    SELECT jk2d_posts.id as var_id, jk2d_posts.post_parent as ID, COUNT(jk2d_posts.id) as meta_count FROM jk2d_posts
    INNER JOIN jk2d_postmeta AS pf1 ON (jk2d_posts.ID = pf1.post_id)
    WHERE jk2d_posts.post_type = “product_variation”
    AND jk2d_posts.post_status != “trash”
    AND pf1.meta_key IN (“attribute_pa_color”) AND pf1.meta_value IN (“red”)
    GROUP BY jk2d_posts.id
    ) as filtered_post
    INNER JOIN
    (
    SELECT ID, MAX(meta_count) as max_meta_count FROM
    (
    SELECT jk2d_posts.id as var_id, jk2d_posts.post_parent as ID, COUNT(jk2d_posts.id) as meta_count FROM jk2d_posts
    INNER JOIN jk2d_postmeta AS pf1 ON (jk2d_posts.ID = pf1.post_id)
    WHERE jk2d_posts.post_type = “product_variation”
    AND pf1.meta_key IN (“attribute_pa_color”) AND pf1.meta_value IN (“red”)
    GROUP BY jk2d_posts.id
    ) as max_filtered_post
    GROUP BY ID
    ) as max_filtered_post ON max_filtered_post.ID = filtered_post.ID AND max_filtered_post.max_meta_count = filtered_post.meta_count
    LEFT JOIN
    (
    SELECT wp_posts.id as id, COALESCE(stock_table_init.out_of_stock_init1, “0”) as out_of_stock_init
    FROM wp_posts
    LEFT JOIN (
    SELECT jk2d_posts.id as id, “1” as out_of_stock_init1
    FROM jk2d_posts
    WHERE jk2d_posts.id IN
    (
    SELECT object_id FROM jk2d_term_relationships
    WHERE term_taxonomy_id IN ( 10 )
    )
    ) as stock_table_init on wp_posts.id = stock_table_init.id
    GROUP BY id
    ) as stock_table
    ON filtered_post.var_id = stock_table.id
    GROUP BY filtered_post.ID, out_of_stock
    ) as filtered_post
    GROUP BY filtered_post.ID
    HAVING post_count = 1 AND out_of_stock = 1
    made by require(‘wp-blog-header.php’), require_once(‘wp-includes/template-loader.php’), include(‘/themes/vantage-child/woocommerce/archive-product.php’), do_shortcode, preg_replace_callback, do_shortcode_tag, BeRocket_AAPF_single_filter->shortcode, the_widget, BeRocket_new_AAPF_Widget_single->widget, the_widget, BeRocket_AAPF_Widget->widget, BeRocket_AAPF_Widget::get_attribute_values, apply_filters(‘berocket_add_out_of_stock_variable’), WP_Hook->apply_filters, BeRocket_AAPF_compat_woocommerce_variation::out_of_stock_variable
    [01-May-2019 16:04:33 UTC] WordPress database error Table ‘database_name.wp_posts’ doesn’t exist for query
    SELECT filtered_post.id, filtered_post.out_of_stock, COUNT(filtered_post.ID) as post_count FROM
    (
    SELECT filtered_post.*, max_filtered_post.max_meta_count, stock_table.out_of_stock_init as out_of_stock FROM
    (
    SELECT jk2d_posts.id as var_id, jk2d_posts.post_parent as ID, COUNT(jk2d_posts.id) as meta_count FROM jk2d_posts
    INNER JOIN jk2d_postmeta AS pf1 ON (jk2d_posts.ID = pf1.post_id)
    WHERE jk2d_posts.post_type = “product_variation”
    AND jk2d_posts.post_status != “trash”
    AND pf1.meta_key IN (“attribute_pa_color”) AND pf1.meta_value IN (“silver”)
    GROUP BY jk2d_posts.id
    ) as filtered_post
    INNER JOIN
    (
    SELECT ID, MAX(meta_count) as max_meta_count FROM
    (
    SELECT jk2d_posts.id as var_id, jk2d_posts.post_parent as ID, COUNT(jk2d_posts.id) as meta_count FROM jk2d_posts
    INNER JOIN jk2d_postmeta AS pf1 ON (jk2d_posts.ID = pf1.post_id)
    WHERE jk2d_posts.post_type = “product_variation”
    AND pf1.meta_key IN (“attribute_pa_color”) AND pf1.meta_value IN (“silver”)
    GROUP BY jk2d_posts.id
    ) as max_filtered_post
    GROUP BY ID
    ) as max_filtered_post ON max_filtered_post.ID = filtered_post.ID AND max_filtered_post.max_meta_count = filtered_post.meta_count
    LEFT JOIN
    (
    SELECT wp_posts.id as id, COALESCE(stock_table_init.out_of_stock_init1, “0”) as out_of_stock_init
    FROM wp_posts
    LEFT JOIN (
    SELECT jk2d_posts.id as id, “1” as out_of_stock_init1
    FROM jk2d_posts
    WHERE jk2d_posts.id IN
    (
    SELECT object_id FROM jk2d_term_relationships
    WHERE term_taxonomy_id IN ( 10 )
    )
    ) as stock_table_init on wp_posts.id = stock_table_init.id
    GROUP BY id
    ) as stock_table
    ON filtered_post.var_id = stock_table.id
    GROUP BY filtered_post.ID, out_of_stock
    ) as filtered_post
    GROUP BY filtered_post.ID
    HAVING post_count = 1 AND out_of_stock = 1
    made by require(‘wp-blog-header.php’), require_once(‘wp-includes/template-loader.php’), include(‘/themes/vantage-child/woocommerce/archive-product.php’), do_shortcode, preg_replace_callback, do_shortcode_tag, BeRocket_AAPF_single_filter->shortcode, the_widget, BeRocket_new_AAPF_Widget_single->widget, the_widget, BeRocket_AAPF_Widget->widget, BeRocket_AAPF_Widget::get_attribute_values, apply_filters(‘berocket_add_out_of_stock_variable’), WP_Hook->apply_filters, BeRocket_AAPF_compat_woocommerce_variation::out_of_stock_variable
    [01-May-2019 16:04:33 UTC] WordPress database error Table ‘database_name.wp_posts’ doesn’t exist for query
    SELECT filtered_post.id, filtered_post.out_of_stock, COUNT(filtered_post.ID) as post_count FROM
    (
    SELECT filtered_post.*, max_filtered_post.max_meta_count, stock_table.out_of_stock_init as out_of_stock FROM
    (
    SELECT jk2d_posts.id as var_id, jk2d_posts.post_parent as ID, COUNT(jk2d_posts.id) as meta_count FROM jk2d_posts
    INNER JOIN jk2d_postmeta AS pf1 ON (jk2d_posts.ID = pf1.post_id)
    WHERE jk2d_posts.post_type = “product_variation”
    AND jk2d_posts.post_status != “trash”
    AND pf1.meta_key IN (“attribute_pa_color”) AND pf1.meta_value IN (“yellow”)
    GROUP BY jk2d_posts.id
    ) as filtered_post
    INNER JOIN
    (
    SELECT ID, MAX(meta_count) as max_meta_count FROM
    (
    SELECT jk2d_posts.id as var_id, jk2d_posts.post_parent as ID, COUNT(jk2d_posts.id) as meta_count FROM jk2d_posts
    INNER JOIN jk2d_postmeta AS pf1 ON (jk2d_posts.ID = pf1.post_id)
    WHERE jk2d_posts.post_type = “product_variation”
    AND pf1.meta_key IN (“attribute_pa_color”) AND pf1.meta_value IN (“yellow”)
    GROUP BY jk2d_posts.id
    ) as max_filtered_post
    GROUP BY ID
    ) as max_filtered_post ON max_filtered_post.ID = filtered_post.ID AND max_filtered_post.max_meta_count = filtered_post.meta_count
    LEFT JOIN
    (
    SELECT wp_posts.id as id, COALESCE(stock_table_init.out_of_stock_init1, “0”) as out_of_stock_init
    FROM wp_posts
    LEFT JOIN (
    SELECT jk2d_posts.id as id, “1” as out_of_stock_init1
    FROM jk2d_posts
    WHERE jk2d_posts.id IN
    (
    SELECT object_id FROM jk2d_term_relationships
    WHERE term_taxonomy_id IN ( 10 )
    )
    ) as stock_table_init on wp_posts.id = stock_table_init.id
    GROUP BY id
    ) as stock_table
    ON filtered_post.var_id = stock_table.id
    GROUP BY filtered_post.ID, out_of_stock
    ) as filtered_post
    GROUP BY filtered_post.ID
    HAVING post_count = 1 AND out_of_stock = 1
    made by require(‘wp-blog-header.php’), require_once(‘wp-includes/template-loader.php’), include(‘/themes/vantage-child/woocommerce/archive-product.php’), do_shortcode, preg_replace_callback, do_shortcode_tag, BeRocket_AAPF_single_filter->shortcode, the_widget, BeRocket_new_AAPF_Widget_single->widget, the_widget, BeRocket_AAPF_Widget->widget, BeRocket_AAPF_Widget::get_attribute_values, apply_filters(‘berocket_add_out_of_stock_variable’), WP_Hook->apply_filters, BeRocket_AAPF_compat_woocommerce_variation::out_of_stock_variable

    I am getting this when I enable WP debug. The filter works correctly itself.
    Thanks.

Viewing 8 replies - 1 through 8 (of 8 total)
  • Plugin Author Dima Holovnia

    (@dholovnia)

    Hello,

    Thank you for the message. We will check it asap and get back to you.

    Regards,
    Dima

    I have the same problem after the last update…

    there are 3 errors in the file woocommerce-ajax-filters/includes/addons/woocommerce-variation.php from line 95 to 105.
    Change from:

    SELECT wp_posts.id as id, COALESCE(stock_table_init.out_of_stock_init1, "0") as out_of_stock_init
            FROM wp_posts
            LEFT JOIN (
                SELECT %1$s.id as id, "1" as out_of_stock_init1
                FROM %1$s
                ' . apply_filters('brAAPFcompat_WCvariation_out_of_stock_where', 'WHERE %1$s.id IN
                (
                    SELECT object_id FROM %3$s
                    WHERE term_taxonomy_id IN ( '.$outofstock.' )
                ) ') . '
            ) as stock_table_init on wp_posts.id = stock_table_init.id

    to:

    SELECT '.$wpdb->posts.'.id as id, COALESCE(stock_table_init.out_of_stock_init1, "0") as out_of_stock_init
            FROM '.$wpdb->posts.'
            LEFT JOIN (
                SELECT %1$s.id as id, "1" as out_of_stock_init1
                FROM %1$s
                ' . apply_filters('brAAPFcompat_WCvariation_out_of_stock_where', 'WHERE %1$s.id IN
                (
                    SELECT object_id FROM %3$s
                    WHERE term_taxonomy_id IN ( '.$outofstock.' )
                ) ') . '
            ) as stock_table_init on '.$wpdb->posts.'.id = stock_table_init.id

    Well done clever man 🙂
    Now it’s working without errors.
    Thank you.

    Please, correct the bug with the next update.

    Plugin Author Dima Holovnia

    (@dholovnia)

    New version with fix was release 2 hours ago.

    Ok, sorry I didn’t notice. Thank you.

    Plugin Author Dima Holovnia

    (@dholovnia)

    Did you try updated version already? Is everything ok there?

    Regards,
    Dima

    Hi.
    Yes, the issue was fixed, thank you.

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘WordPress database error’ is closed to new replies.