Skip to content

Fix for incorrect ticket count in query when running more than on provider. #3594

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

Camwyn
Copy link
Member

@Camwyn Camwyn commented Feb 25, 2025

Discovered while doing prelim work for presets. ETP-988
ET-2317

This line:
$args['meta_query'] = array_merge( (array) $args['meta_query'], (array) $module_args['meta_query'] );

Overwrites the relation set in $args with the default "AND"

So if we are running two providers (such as TC and RSVP) and we check for ticket IDs on a post (with an ID of 215 below) the final query will be:

$query = [
	[post_type]      => [
		[rsvp] => tribe_rsvp_tickets,
		[0]    => tec_tc_ticket,
	],
	[posts_per_page] => -1,
	[fields]          => ids,
	[post_status]    => publish,
	[order_by]       => menu_order,
	[order]          => ASC,
	[meta_query]     => [
		[relation]                       => AND,
		[_tribe_rsvp_for_event_in]       => [
			[key]     => _tribe_rsvp_for_event
			[compare] => IN
			[value]   => [ [0] => 215 ]

		
		],
		[_tec_tickets_commerce_event_in] => [
			[key]     => _tec_tickets_commerce_event
			[compare] => IN
			[value]   => [ [0] => 215 ]

		
		],
	]
];

Note the "AND" - so this will fail, and the function will always return 0 tickets found. It can't be both an RSVP AND a ticket (or a ticket from two providers simultaneously).

Also fixed the docblocks for get_tickets_ids() and the called Tribe__Tickets__Tickets::set_tickets_query_args() as neither can currently handle getting a post object passed to them 😞

@Camwyn Camwyn added hold Status: on hold–do not proceed with other status items. needs ticket Needs an associated Jira ticket before merging. needs release Needs an associated release in Jira before merging. labels Feb 25, 2025
@Camwyn Camwyn self-assigned this Feb 25, 2025
@Camwyn Camwyn changed the title Fix for incorrect ticket count in query when running more than on proider. Fix for incorrect ticket count in query when running more than on provider. Feb 25, 2025
Copy link
Member

@dpanta94 dpanta94 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems like a good change but kinda worried of what we might be breaking because of that. I would check ETP's test as well how they behave with that change in place.

@Camwyn
Copy link
Member Author

Camwyn commented Feb 26, 2025

This seems like a good change but kinda worried of what we might be breaking because of that. I would check ETP's test as well how they behave with that change in place.

PR: https://github.com/the-events-calendar/event-tickets-plus/pull/1770

@Camwyn Camwyn force-pushed the fix/ticket-preset-ticket-query branch from 10b097f to e5bda4d Compare March 7, 2025 03:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
hold Status: on hold–do not proceed with other status items. needs release Needs an associated release in Jira before merging. needs ticket Needs an associated Jira ticket before merging.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants