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

seddonym’s picture

Here's the patch.

wamilton’s picture

Status: Active » Needs review

there's a patch, so I'm updating the status

levelos’s picture

Status: Needs review » Fixed
matt.elkins’s picture

Status: Fixed » Needs work

I'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:

  1. Register for a host entity up to the capacity defined in the settings.
  2. Access the "Manage Registrations" tab for the host entity and edit a registration.
  3. Reduce the number of slots for the chosen registration and attempt to save the changes - the validation error will be displayed.

I'm working on a patch to fix this at the moment.

matt.elkins’s picture

Status: Needs work » Needs review
StatusFileSize
new7.29 KB

As promised, patch attached.

dijup tuladhar’s picture

I 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.

sheldonkreger’s picture

Status: Needs review » Reviewed & tested by the community

#5 works for me, thanks matt.elkins!

levelos’s picture

Status: Reviewed & tested by the community » Needs work

@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".

matt.elkins’s picture

Status: Needs work » Fixed

Thanks @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).

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

  • levelos committed e850fbf on 7.x-1.x, panels, any-entity, slots, integrations, hold_state authored by seddonym
    #1717466 by seddonym: Change registration_has_room() signature to...