From 83cb211680ce9f3a5432ee746249017f15616495 Mon Sep 17 00:00:00 2001 From: Pedro Amorim Date: Mon, 11 Nov 2024 15:31:11 -0100 Subject: [PATCH] fix: prevent milestone progress overflow --- code/web/sys/Community/CampaignMilestone.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/code/web/sys/Community/CampaignMilestone.php b/code/web/sys/Community/CampaignMilestone.php index 4d3a4a802a..856c45b378 100644 --- a/code/web/sys/Community/CampaignMilestone.php +++ b/code/web/sys/Community/CampaignMilestone.php @@ -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(); }