Participants having multiple roles affects maximum event registration count
If you add multiple participant roles for a participant entry, it affects the event full count.
Steps to reproduce
- On dmaster, create a new event
- Enable online registration and set "Max Number of Participants" to 1
- Go to live event registration page. You should be able to register
- Now add a new registration to a different contact from backend.
- Once again go to live event registration page. Now it should show the event full message.
- Go back to the other contact's events. Edit the event participant entry and add another role such as "Host".
- Now go to the event registration page and you will be able to register for the maxed out event
Issue
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'
. This is a simple workaround I could think of. Haven't tested in all other scenarios.
$regexp = "([[:cntrl:]]|^)" . implode('([[:cntrl:]]|$)|([[:cntrl:]]|^)', $escapedRoles) . "([[:cntrl:]]|$)";
$where[] = " participant.role_id REGEXP '{$regexp}'";