The problem is with registration_has_room():
function registration_has_room($entity_type, $entity_id, $slots = 0, $registration_id = NULL) {
$settings = registration_entity_settings($entity_type, $entity_id);
$capacity = $settings['capacity'];
if ($capacity) {
$count = registration_event_count($entity_type, $entity_id, $registration_id) + $slots;
if (($capacity - $count) < 0) {
return FALSE;
}
}
return TRUE;
}
This function is designed to return whether or not there is room for any more registrations. Optionally you can specify the number of slots, to see if there are, say, two slots available.
The default value of slots is 0. I think this is wrong, it should be 1. Currently calling registration_has_room() without specifying slots returns TRUE if the entity instance has reached capacity, since it reports (correctly) that there is room for 0 slots to be added. This is why the call in registration_status() fails:
// check capacity
if (!registration_has_room($entity_type, $entity_id)) {
$status = FALSE;
}
The function signature should therefore be:
function registration_has_room($entity_type, $entity_id, $slots = 1, $registration_id = NULL) {
If I get a chance I'll submit a patch.
Comments
Comment #1
seddonym commentedHere's the patch.
Comment #2
wamilton commentedthere's a patch, so I'm updating the status
Comment #3
levelos commentedComment #4
matt.elkins commentedI'm glad I searched the issues list, as I was just about starting working on a patch for this problem myself! However, I think the patch provided in #1 has introduced another bug unfortunately. When attempting to edit a registration for a fully booked host entity, validation for the registration form fails with the error "Registrations are no longer available for ...".
Steps to reproduce:
I'm working on a patch to fix this at the moment.
Comment #5
matt.elkins commentedAs promised, patch attached.
Comment #6
dijup tuladhar commentedI think it will be great if can we add the minimum limit for the room. In many case we want the minimum no of participant to be there for the event.
Comment #7
sheldonkreger commented#5 works for me, thanks matt.elkins!
Comment #8
levelos commented@matt.elkins, could you re-roll the patch in #5 against head if the issue is still applicable. It does not apply in it's current version. For that matter, I think that it's a separate issue worthy of its own ticket along the lines of "validation fails for existing registration at capacity".
Comment #9
matt.elkins commentedThanks @levelos, this specific issue has been fixed in the latest version of 7.x-1.x-dev, and my patch in #5 is no longer valid. However, there does seem to still be a problem with the capacity validation, which I'll post as a new item in the issue queue (if a ticket describing the bug doesn't already exist).