• Resolved Mike Meinz

    (@mikemeinz)


    The following error is logged in the wp-admin PHP error_log whenever a search is done in the Media Library.

    [27-Sep-2025 14:05:31 UTC] WordPress database error Not unique table/alias: 'wp_postmeta' for query SELECT SQL_CALC_FOUND_ROWS DISTINCT wp_posts.ID
    FROM wp_posts INNER JOIN wp_postmeta ON ( wp_posts.ID = wp_postmeta.post_id ) LEFT JOIN wp_postmeta ON wp_posts.ID = wp_postmeta.post_id LEFT JOIN wp_term_relationships AS trel ON (wp_posts.ID = trel.object_id) LEFT JOIN wp_term_taxonomy AS ttax ON (( ttax.taxonomy = 'ml-slider' ) AND trel.term_taxonomy_id = ttax.term_taxonomy_id) LEFT JOIN wp_terms AS tter ON (ttax.term_id = tter.term_id)
    WHERE 1=1 AND wp_posts.post_type = 'attachment' AND (wp_posts.post_status = 'inherit' OR wp_posts.post_status = 'private') AND ( (wp_posts.ID LIKE '%Brochure%') OR (wp_posts.post_title LIKE '%Brochure%') OR (wp_posts.guid LIKE '%Brochure%') OR (wp_posts.post_content LIKE '%Brochure%') OR (wp_posts.post_excerpt LIKE '%Brochure%') OR (wp_postmeta.meta_key = '_wp_attachment_image_alt' AND wp_postmeta.meta_value LIKE '%Brochure%') OR (wp_postmeta.meta_key = '_wp_attached_file' AND wp_postmeta.meta_value LIKE '%Brochure%') OR (tter.slug LIKE '%Brochure%') OR (ttax.description LIKE '%Brochure%') OR (tter.name LIKE '%Brochure%') )
    GROUP BY wp_posts.ID
    ORDER BY wp_posts.post_date DESC
    LIMIT 0, 100 made by require_once('wp-admin/admin-header.php'), do_action('admin_enqueue_scripts'), WP_Hook->do_action, WP_Hook->apply_filters, PublishPress\Future\Modules\Workflows\Controllers\FutureLegacyAction->enqueueScriptsLegacyAction, PublishPress\Future\Modules\Workflows\Models\WorkflowsModel->getPublishedWorkflowsWithLegacyTriggerAsOptions, PublishPress\Future\Modules\Workflows\Models\WorkflowsModel->getPublishedWorkflowsWithMetadataAsOptions, WP_Query->__construct, WP_Query->query, WP_Query->get_posts

    It appears that line 203 in class-media-search-enhanced.php doesn’t use an alias for the wp_postmeta table. Using an alias in line 203 and the other places where wp_postmeta is used would resolve this issue. Thanks!

            $pieces['join'] .= " LEFT JOIN $wpdb->postmeta ON $wpdb->posts.ID = $wpdb->postmeta.post_id";

    Media Search Enhanced Version 0.9.0 
    WordPress Version 6.8.2

    • This topic was modified 4 months, 3 weeks ago by Mike Meinz.
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.