• Resolved Klaus Spithost

    (@spithost)


    I get lots of errors in the logs of one of the websites I maintain that use WooCommerce. The errors look like:
    =============
    [10-Dec-2018 18:42:58 UTC] WordPress databasefout Unknown column ‘wp_postmeta.meta_value’ in ‘order clause’ bij query SELECT wp_posts.ID FROM wp_posts WHERE 1=1 AND wp_posts.post_type = ‘post’ AND ((wp_posts.post_status = ‘publish’)) ORDER BY wp_postmeta.meta_value+0 DESC, wp_posts.post_date DESC LIMIT 0, 3 gemaakt door require(‘wp-blog-header.php’), require_once(‘wp-includes/template-loader.php’), include(‘/plugins/woocommerce/templates/archive-product.php’), do_action(‘woocommerce_sidebar’), WP_Hook->do_action, WP_Hook->apply_filters, Avada_Woocommerce->add_sidebar, do_action(‘avada_after_content’), WP_Hook->do_action, WP_Hook->apply_filters, Avada_Layout->append_sidebar_single, get_template_part, locate_template, load_template, require(‘/themes/Avada/templates/sidebar-1.php’), generated_dynamic_sidebar, Sidebar_Generator::get_sidebar, dynamic_sidebar, WP_Widget->display_callback, WP_Widget_Recent_Posts->widget, WP_Query->__construct, WP_Query->query, WP_Query->get_posts
    =============
    Somehow the query tries to order results on a column NOT being available from the basic query (which only asks for wp_posts.ID).
    As (part of) WooCommerce is mentioned in the error-line as a plugin, I suspect WooCommerce creating these errors in templates/archive-product.php but it could easily be something else mentioned in the errorlines ??
    Anybody got suggestions?!
    Running WooCommerce 3.5.2 on a WordPress 5.0 website with Avada as the theme.
    Regards,
    Klaus

Viewing 4 replies - 1 through 4 (of 4 total)
  • Howdy Klaus,

    The error message looks to me like it’s complaining of a missing column in the wp_postmeta table. I would suggest that you have a look at the database and confirm whether that column exists and if it doesn’t get that fixed up.

    You can use a plugin like ARI Adminer https://www.ads-software.com/plugins/ari-adminer/ to browse the database.You would be looking for something like this:

    to verify if the column exists.

    Kind regards,

    Thread Starter Klaus Spithost

    (@spithost)

    Hi W,

    Thanks for the reply!

    Checking the existance of the wp_postmeta.meta-column was the first thing I checked and the column exists (I use phpMyAdmin by the way).

    After that I looked at the complete query that is done: SELECT wp_posts.ID FROM wp_posts WHERE 1=1 AND wp_posts.post_type = ‘post’ AND ((wp_posts.post_status = ‘publish’)) ORDER BY wp_postmeta.meta_value+0 DESC, wp_posts.post_date DESC LIMIT 0, 3.

    If you look at the first part of the query: SELECT wp_posts.ID FROM wp_posts, you can see that only wp_posts.ID is asked from the database, and then “ORDERing” the results on a field that isn’t asked in the original query doesn’t seem very logical.

    So THAT’s why I entered my question here. To find out exactly where the query is coming from and get the developers to expand the query to also take the corresponding fields from the wp_postmeta table (which then propably also will have to be JOINed in some way to the ID’s from the wp_posts-table) to get all nessesary fields in the result.
    Because there’s mentioning of WooCommerce as “part of” the codepiece that produces the error, I suspect a ommision in WooCommerce somewhere but I’m not sure….

    jessepearson

    (@jessepearson)

    Automattic Happiness Engineer

    @spithost I looked into the code for WooCommerce itself and that query is not from WooCommerce. It looks like this starts with the WP_Widget_Recent_Posts class, which is the built in recent posts widget. There’s no sorting/ordering for this widget, but the query is filterable, so maybe there is something in a plugin or the theme that’s adding the sorting and is causing the issue.

    Plugin Support con

    (@conschneider)

    Engineer

    Hi there,

    We haven’t heard back from you in a while, so I’m going to mark this as resolved – if you have any further questions, you can start a new thread.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘database-error from WooCommerce?’ is closed to new replies.