Skip to content

Conversation

@edwh
Copy link
Collaborator

@edwh edwh commented Jan 15, 2026

Summary

  • Fixes bug where deleting event invitations incorrectly decremented the volunteer count
  • The EventsUsersObserver::deleted() method passed 4 parameters to removed() which only accepts 3, causing the status check to be silently ignored
  • Every deleted events_users record was decrementing the count, even for invited (non-confirmed) users who were never counted

Root Cause

Line 89 in EventsUsersObserver.php:

// Bug: 4th parameter is silently ignored
$this->removed($event, $user, true, $eu->status == 1);

// Fix: Pass status check as the $count parameter
$this->removed($event, $user, $eu->status == 1);

Changes

  1. One-line fix in EventsUsersObserver.php - correctly pass $eu->status == 1 as the $count parameter
  2. Migration to fix all existing events with incorrect volunteer counts
  3. Three new tests to prevent regression:
    • testDeletingInvitedVolunteerDoesNotDecrementCount
    • testDeletingConfirmedVolunteerDecrementsCount
    • testMultipleInvitationDeletionsCauseNegativeCount
  4. Updated CLAUDE.md with Task/Docker documentation

Test plan

  • New unit tests pass locally
  • Verify negative counts are fixed after migration runs on staging
  • Manual test: invite user to event, delete invitation, verify count stays at 0

The EventsUsersObserver::deleted() method was incorrectly decrementing
the volunteer count for ALL deleted events_users records, not just
confirmed volunteers.

Bug: Line 89 passed 4 parameters to removed() which only accepts 3.
The 4th parameter ($eu->status == 1) was silently ignored, so $count
was always true, causing incorrect decrements when invitations
(non-confirmed users) were deleted.

Fix: Pass $eu->status == 1 as the 3rd parameter instead of true.

Also includes:
- Migration to fix existing incorrect volunteer counts
- Three new tests to prevent regression
- Updated CLAUDE.md with Task/Docker documentation
@sonarqubecloud
Copy link

Quality Gate Failed Quality Gate failed

Failed conditions
25.2% Duplication on New Code (required ≤ 3%)

See analysis details on SonarQube Cloud

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants