strangerstudios / pmpro-events

Offer members-only events using popular events plugins and Paid Memberships Pro.
https://www.paidmembershipspro.com/add-ons/events-for-members-only/
8 stars 10 forks source link

Not unique table/alias database error with The Events Calendar #52

Open dwanjuki opened 1 year ago

dwanjuki commented 1 year ago

Describe the bug Visiting The Events Calendar's events page triggers the following database error WordPress database error: [Not unique table/alias: 'wp_tec_occurrences']

Related PR: https://github.com/strangerstudios/pmpro-events/pull/49

Not unique table/alias: 'wp_tests_tec_occurrences' for query SELECT SQL_CALC_FOUND_ROWS wp_tests_posts.ID FROM wp_tests_posts LEFT JOIN wp_tests_term_relationships ON (wp_tests_posts.ID = wp_tests_term_relationships.object_id) LEFT JOIN wp_tests_term_relationships AS tt1 ON (wp_tests_posts.ID = tt1.object_id) LEFT JOIN wp_tests_term_relationships AS tt2 ON (wp_tests_posts.ID = tt2.object_id) INNER JOIN wp_tests_tec_occurrences ON wp_tests_posts.ID = wp_tests_tec_occurrences.post_id LEFT JOIN `wp_tests_pmpro_memberships_pages` AS `pmpro_mp_5` ON `pmpro_mp_5`.`page_id` = `wp_tests_posts`.`ID` JOIN wp_tests_tec_occurrences ON wp_tests_posts.ID = wp_tests_tec_occurrences.post_id WHERE 1=1 AND wp_tests_posts.ID NOT IN (43,449,816,945,1509,43,449,816,945,1509) AND ( wp_tests_term_relationships.term_taxonomy_id IN (3) AND tt1.term_taxonomy_id IN (3) AND tt2.term_taxonomy_id IN (1,3,59,76,82,84,95) ) AND ( CAST(wp_tests_tec_occurrences.end_date AS DATETIME) < '2023-08-21 07:39:06' ) AND wp_tests_posts.post_type = 'tribe_events' AND ((wp_tests_posts.post_status = 'publish' OR wp_tests_posts.post_status = 'private')) AND (pmpro_mp_5.membership_id IS NULL OR pmpro_mp_5.membership_id IN ( 2 )) GROUP BY wp_tests_tec_occurrences.occurrence_id ORDER BY wp_tests_posts.post_date ASC LIMIT 0, 1 made by require('wp-blog-header.php'), require_once('wp-includes/template-loader.php'), include('/plugins/the-events-calendar/src/views/v2/default-template.php'), Tribe\Events\Views\V2\Template_Bootstrap->get_view_html, Tribe\Events\Views\V2\View->get_html, Tribe\Events\Views\V2\Views\List_View->setup_template_vars, Tribe\Events\Views\V2\View->setup_template_vars, Tribe\Events\Views\V2\Views\List_View->prev_url, Tribe\Events\Views\V2\Views\List_View->get_past_url, Tribe__Repository->count, WP_Query->get_posts, apply_filters_ref_array('posts_pre_query'), WP_Hook->apply_filters, TEC\Events\Custom_Tables\V1\WP_Query\Modifiers\Events_Only_Modifier->filter_posts_pre_query, TEC\Events\Custom_Tables\V1\WP_Query\Custom_Tables_Query->get_posts, WP_Query->get_posts

To Reproduce Steps to reproduce the behavior:

  1. Activate PMPro, The Events Calendar, and the PMPro Events Add On.
  2. Visit the Events List page with debugging enabled.
  3. Check debug log, see error

Expected behavior No errors

Isolating the problem (mark completed items with an [x]):

WordPress Environment

PHP 8.0.29 WordPress 6.3 PMPro 2.10.2 The Events Calendar 6.2.0.1 PMPro Events 1.4
dwanjuki commented 1 year ago

Furthermore, when the Add On is active, no events are displayed on the Events archive page, or where the [tribe_events] shortcode is used.

andrewlimaza commented 11 months ago

@dwanjuki please can you retest the Events archive page with the latest version. This issue seems to have been resolved on my end and I haven't been able to replicate it recently.