Hello,

In case I have an entity with 2 slots +1 in the waiting list enabled, registration_status() returns false if there is one (non wait list) registration and one (wait list) registration. This can happen in case a user who register on the main list then cancel/delete his registration. In my opinion, it should return true since the total number of slots have not been filled yet.

To do so, replace (in waiting_list.module)

<?php
    // We only need to check how many people are on the waitlist if there is a capacity other than 0 set
    if ($active && $waitlist_capacity) {
      $waitlist_state = registration_get_states(REGISTRATION_WAITLIST_STATE);
      // get count of registrations with the waitlist state
      $query = db_select('registration', 'r');
      $query->addExpression('sum(count)', 'count');
      $query->condition('entity_id', $entity_id);
      $query->condition('entity_type', $entity_type);
      $query->condition('state', $waitlist_state->identifier());
      $result = $query->execute();
      $waitlist_count = $result->fetchField();
      $waitlist_count = ($waitlist_count == '') ? 0 : $waitlist_count;

      if (($waitlist_capacity - $waitlist_count) < 1) {
        $active = FALSE;
        $errors[] = t('waitlist is full');
      }
    }
?>

by

<?php
    // We only need to check how many people are on the waitlist if there is a capacity other than 0 set
    if ($active && $waitlist_capacity) {
      $waitlist_state = registration_get_states(REGISTRATION_WAITLIST_STATE);
      $canceled_state = registration_get_states('canceled');      
      // get count of registrations with the waitlist state
      $query = db_select('registration', 'r');
      $query->addExpression('sum(count)', 'count');
      $query->condition('entity_id', $entity_id);
      $query->condition('entity_type', $entity_type);
//       $query->condition('state', $waitlist_state->identifier());
      $query->condition('state', $canceled_state->identifier(), '<>');
      $result = $query->execute();
      $total_count = $result->fetchField();
      $total_count = ($total_count == '') ? 0 : $total_count;

      // compare the total number of registrations to the sum of capacity and waiting list capacity
      // allow to handle the case where normal applications have been deleted.
      if (($capacity + $waitlist_capacity - $total_count) < 1) {
        $active = FALSE;
        $errors[] = t('waitlist is full');
      }
    }
?>

Please tell me if it is a bug or if it works as designed.

EDIT: patch provided.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

julou’s picture

gcb’s picture

Status: Needs review » Needs work

I agree that this behavior is not ideal, but it seems like the correct way to deal with it is actually to convert the oldest waitlist registration into a full registration in this case.

gandhiano’s picture

Priority: Normal » Major
Issue tags: +waitlist

The patch on #1 (applied on 7.x-1.3) is not working for me, I still always get an:

Error message: Sorry, unable to register for SOME EVENT due to: insufficient spaces remaining.

Even if there is only people in the waiting list (after deleting the completed ones).

Pushing priority up, since this makes the waitlist submodule basically unusable.

alibama’s picture

yeah - having problems with waitlist - i'm considering removing from my site as it doesn't really work...

Renee S’s picture

I solved this by creating a rule that moves people off the waitlist. Perhaps give this a shot? #2481203: Make module more waitlist-aware, bonus: making waitlist work!

ETA: Now there's this solution too: https://www.drupal.org/node/2258117

dsnopek’s picture

Status: Needs work » Closed (duplicate)

I'm pretty sure this is a duplicate of #2496559: Event Count not accurately counting active/held states. The main module is counting the number of registered participants wrong - this shouldn't require changing registration_waitlist to account for the waitlisted registrations.

But if I've got this wrong, please feel free to re-open this issue! :-)