Skip to content

Commit

Permalink
fix: prevent milestone progress overflow
Browse files Browse the repository at this point in the history
  • Loading branch information
ammopt committed Nov 11, 2024
1 parent 69f3ad2 commit 83cb211
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions code/web/sys/Community/CampaignMilestone.php
Original file line number Diff line number Diff line change
Expand Up @@ -200,8 +200,13 @@ public function addCampaignMilestoneProgressEntry( $object, $userId)
$campaignMilestoneUsersProgress->ce_campaign_id = $this->campaignId;
$campaignMilestoneUsersProgress->userId = $userId;

# If there isn't one, create it.
if (!$campaignMilestoneUsersProgress->find(true)) {
# There is one, bail if goal has already been met
if ($campaignMilestoneUsersProgress->find(true)) {
if ($campaignMilestoneUsersProgress->progress >= $this->goal) {
return;
}
# There isn't one, create it.
} else {
$campaignMilestoneUsersProgress->progress = 0;
$campaignMilestoneUsersProgress->insert();
}
Expand Down

0 comments on commit 83cb211

Please sign in to comment.