Sorry if this is a duplicate of others, since there's a few issues that might apply here.
I'm not sure if this is an issue or the intended design, but some review would be good on a specific section of `registration.module` and the function `registration_event_count()`.
Right now, the code runs as follows:
<?php
$active_held_states = registration_states(array('held' => TRUE, 'active' => TRUE));
if (!empty($active_held_states)) {
$query->condition('state', $active_held_states, 'IN');
}
?>But where I'm getting lost on it is that this is grabbing registration states that are BOTH held and active, since `registration_states()` will accept condition parameters and add them separately as property conditions (i.e. AND select statements in SQL not OR). According to the validation patch in the DEV version on line 965 in `includes/registration.forms.inc` states can only be held OR active, so this check should never run, in theory.
Without that form validation, when a state is set to both held and active the system will return a fatal error, because registration objects are passed to the query condition, rather than arrays, which is described in Issue 2469985.
So I think it should be as follows:
<?php
$active_held_states = array_merge(registration_get_active_states(), registration_get_held_states());
if (!empty($active_held_states)) {
$query->condition('state', $active_held_states, 'IN');
}
?>This appears to work on our testing site, but it would be good to get some feedback since ours is a limited use case.
| Comment | File | Size | Author |
|---|---|---|---|
| #1 | registration-event-count-fix-2496559.patch | 655 bytes | .bert |
Comments
Comment #1
.bert commentedComment #2
aj2 commentedI'm having the same issue, where a registration state that does not have an active or held configuration is being held against the total available spots. I can confirm that the patch in post #1 fixes my issue.
Appears this bug here, is also likely linked to the one here, with a different solution:
https://www.drupal.org/node/2497203
Comment #3
.bert commentedThanks for that aj2. Looks like it's the same solution, just a different way of getting there. I think the patch included here is the better option since it makes use of functions that already return the state identifiers (names).
Comment #4
dsnopekI just closed #2497203: Canceled registrations count towards event count (so you can hit capacity early!) as a duplicate of this issue.
Comment #5
dsnopekWorks for me! :-)
Comment #6
LonitaD commentedThe patch seems to work well. Thanks!
Marking #2487586: Active checkbox for registration state does not change the number of spaces filled as a duplicate of this issue.
Comment #7
nrackleff commentedComment #8
nrackleff commentedComment #9
amytswan commentedComment #10
amytswan commentedThank you .bert, dsnopek, aj2, and creativ180, for your attention to this issue. I've applied your patch .bert, and it is set to go out in our next release!