• Resolved isarisar

    (@isarisar)


    We’ve never had this before, but early yesterday morning, within 1.5h our log got flooded with 162 repetitions the SQL error shown below.

    I’m not sure at all that it’s actually caused by Custom Product Tabs – and sadly I’ve got no idea how to reproduce this either – I’m solely going on the “yikes_woo_products_tabs” mentioned.

    WordPress database error: Not unique table/alias: 'wp_postmeta' for query
                                            SELECT SQL_CALC_FOUND_ROWS DISTINCT wp_posts.ID
                                            FROM wp_posts  LEFT JOIN wp_term_relationships ON (wp_posts.ID = wp_term_relationships.object_id)  LEFT JOIN wp_term_relationships AS tt1 ON (wp_posts.ID = tt1.object_id)  LEFT JOIN wp_term_relationships AS tt2 ON (wp_posts.ID = tt2.object_id) INNER JOIN wp_postmeta ON ( wp_posts.ID = wp_postmeta.post_id ) LEFT OUTER JOIN wp_postmeta ON wp_posts.ID = wp_postmeta.post_id AND wp_postmeta.meta_key = "yikes_woo_products_tabs"
                                            WHERE 1=1  AND (
      wp_term_relationships.term_taxonomy_id IN (190,191,192,193,194,195,196)
      AND
      tt1.term_taxonomy_id IN (232,233,234,235,236,237,239)
      AND
      tt2.term_taxonomy_id IN (227,228,481,482,484)
    ) AND (((wp_posts.post_title LIKE '%1%') OR (wp_postmeta.meta_value LIKE '%1%') OR (wp_posts.post_excerpt LIKE '%1%') OR (wp_posts.post_content LIKE '%1%')))  AND (wp_posts.post_password = '')  AND (
      ( wp_postmeta.meta_key = '_stock_status' AND wp_postmeta.meta_value NOT IN ('outofstock') )
    ) AND wp_posts.post_type = 'product' AND ((wp_posts.post_status = 'publish'))
                                            GROUP BY wp_posts.ID
                                            ORDER BY wp_posts.post_date ASC
                                            LIMIT 0, 21
                                     von require('wp-blog-header.php'), require_once('wp-includes/template-loader.php'), include('/themes/Divi/includes/builder/frontend-builder/theme-builder/frontend-body-template.php'), get_header, locate_template, load_template, require_once('/themes/Divi/header.php'), wp_head, do_action('wp_head'), WP_Hook->do_action, WP_Hook->apply_filters, WPF_Public->result_page, WPF_Public->get_result, query_posts, WP_Query->query, WP_Query->get_posts

    PHP 8.0.20
    WP 6.0.1
    Divi 4.17.6
    WC 6.7.0
    CPT 1.2.2

Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter isarisar

    (@isarisar)

    … and it’s back, this time as

    WordPress database error: Not unique table/alias: 'wp_postmeta' for query
                            SELECT 	 DISTINCT wp_posts.ID
                            FROM wp_posts  LEFT JOIN wp_postmeta ON ( wp_posts.ID = wp_postmeta.post_id AND wp_postmeta.meta_key = '_et_library_theme_builder' ) LEFT OUTER JOIN wp_postmeta ON wp_posts.ID = wp_postmeta.post_id AND wp_postmeta.meta_key = "yikes_woo_products_tabs"
                            WHERE 1=1  AND (
      wp_postmeta.post_id IS NULL
    ) AND wp_posts.post_type = 'et_theme_builder' AND ((wp_posts.post_status = 'publish'))
                            GROUP BY wp_posts.ID
                            ORDER BY wp_posts.post_date DESC
                            LIMIT 0, 1
                     von require('wp-blog-header.php'), wp, WP->main, do_action_ref_array('wp'), WP_Hook->do_action, WP_Hook->apply_filters, et_pb_ab_init, et_builder_ab_get_current_tests, et_theme_builder_get_template_layouts, et_theme_builder_get_theme_builder_templates, et_theme_builder_get_theme_builder_template_ids, et_theme_builder_get_theme_builder_post_id, WP_Query->__construct, WP_Query->query, WP_Query->get_posts
    Thread Starter isarisar

    (@isarisar)

    Note that a 2021 comment in the source you link for search_join mentions exactly this error – along with a fix:

    Had to change these two lines to get it working on WP 5.8.1 as I had an error ( Not unique table/alias: ‘wp_postmeta’ [continues with fixes]

    Thread Starter isarisar

    (@isarisar)

    The updated lines are for search_join

    $join .= ' LEFT OUTER JOIN ' . $wpdb->postmeta .' AS post_metas ON ' . $wpdb->posts . '.ID = post_metas.post_id AND post_metas.meta_key = "yikes_woo_products_tabs"';

    … and for search_where:

    '('.$wpdb->posts.'.post_title LIKE $1) OR (post_metas.meta_value LIKE $1)', $where

    No such errors since.

    Plugin Author Evan Herman

    (@eherman24)

    Hi @isarisar

    We are not running any search_join or any queries like that inside of the plugin, and its not something that has been reported before. Sounds like there might be a conflict with another plugin, or an issue with the database.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘WordPress database error: Not unique table/alias: ‘wp_postmeta’’ is closed to new replies.