Skip to content
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

dev/core#1135 Participants having multiple roles affects maximum event registration count #14844

Merged
merged 1 commit into from
Aug 5, 2019
Merged

Conversation

chamilwijesooriya
Copy link
Contributor

@chamilwijesooriya chamilwijesooriya commented Jul 19, 2019

Participants having multiple roles affects maximum event registration count

Overview

If you add multiple participant roles for a participant entry, it affects the event full count.

Steps to reproduce

  1. On dmaster, create a new event
  2. Enable online registration and set "Max Number of Participants" to 1
  3. Go to live event registration page. You should be able to register
  4. Now add a new registration to a different contact from backend.
  5. Once again go to live event registration page. Now it should show the event full message.
  6. Go back to the other contact's events. Edit the event participant entry and add another role such as "Host".
  7. Now go to the event registration page and you will be able to register for the maxed out event

Technical Details

After inspecting CRM_Event_BAO_Participant::eventFull() the following line assumes there will only be one value in the field

$where[] = " participant.role_id IN ( '" . implode("', '", $escapedRoles) . "' ) ";

Therefore when you have multiple values it won't work properly.

Solution

I used regular expression code that's used in CRM_Event_BAO_Query::whereClauseSingle() under case 'participant_role_id'.

$regexp = "([[:cntrl:]]|^)" . implode('([[:cntrl:]]|$)|([[:cntrl:]]|^)', $escapedRoles) . "([[:cntrl:]]|$)";
$where[] = " participant.role_id REGEXP '{$regexp}'";

Comments

This is a simple workaround I could think of. Haven't tested in all other scenarios.

https://lab.civicrm.org/dev/core/issues/1135

@civibot
Copy link

civibot bot commented Jul 19, 2019

(Standard links)

@civibot civibot bot added the master label Jul 19, 2019
@eileenmcnaughton
Copy link
Contributor

@JKingsnorth are you up for checking this one out?

@JKingsnorth
Copy link
Contributor

@eileenmcnaughton I'll try to take a look tomorrow =]

@JKingsnorth
Copy link
Contributor

Confirmed the issue.

Tested the fix with:

  • event max 1, two counted attendee types - correctly blocks registration
  • event max 1, one uncounted attendee type - correctly allows new registration
  • event max 1, one uncounted and one counted attendee type - correctly blocks registration

Looks OK to me, sorry for the delay.

@eileenmcnaughton
Copy link
Contributor

Merging based on @JKingsnorth review - ideally . we would lock this in with a test

@eileenmcnaughton eileenmcnaughton merged commit adb2d06 into civicrm:master Aug 5, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants