Currently, in the default configuration, registrations with a state of 'canceled' will be included in the event count. If your event has a capacity set, then it'll stop letting people register before having enough active registrations!

The right thing to do, would be to only include states which are 'Active' or 'Held' in the event count.

There is some code in registration_event_count() which looks like it was intended to do exactly that:

    $active_held_states = registration_states(array('held' => TRUE, 'active' => TRUE));
    if (!empty($active_held_states)) {
      $query->condition('state', $active_held_states, 'IN');
    }

However, $active_held_states will always be an empty array, because that call to registration_states() is attempting to return states which are BOTH active and held, which is not possible.

Also, registration_states() returns full registration state entities, not just the names, so even if it did return the right states, the query wouldn't be right anyway.

I'll post a patch to fix in a moment!

Comments

dsnopek’s picture

Status: Active » Needs review
StatusFileSize
new986 bytes

Patch is attached! Please let me know what you think. :-)

.bert’s picture

This could probably be marked as a duplicate of this issue:
https://www.drupal.org/node/2496559

The patch provided in that issue does the same thing as your patch, except makes use of the registration_get_active_states() and registration_get_held_states() functions, which already return arrays with state names only.

dsnopek’s picture

Status: Needs review » Closed (duplicate)
Related issues: +#2496559: Event Count not accurately counting active/held states

Ah, yeah, you're patch is shorter and functionally equivalent so let's say this is a duplicate:

#2496559: Event Count not accurately counting active/held states

Sorry I didn't notice yours before I started work on mine!

.bert’s picture

All good. They were right around the same time and good to see we're on the same page.