Skip to content

Commit

Permalink
bind the value of emailRepeatDelayDays into the query
Browse files Browse the repository at this point in the history
  • Loading branch information
briskt committed Feb 10, 2025
1 parent 03b98d3 commit d145728
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions application/common/components/Emailer.php
Original file line number Diff line number Diff line change
Expand Up @@ -781,14 +781,16 @@ public function sendPasswordExpiringEmails()
JOIN `password` p ON u.id = p.user_id
LEFT JOIN `email_log` e ON u.id = e.user_id
AND e.message_type = 'password-expiring'
AND e.sent_utc >= CURRENT_DATE() - INTERVAL 31 DAY # EMAIL_REPEAT_DELAY_DAYS
AND e.sent_utc >= CURRENT_DATE() - INTERVAL ? DAY
WHERE u.active = 'yes'
AND u.locked = 'no'
AND p.expires_on < CURRENT_DATE() + INTERVAL 15 DAY
AND p.expires_on >= CURRENT_DATE() # send a different message if expired
AND e.id IS NULL
GROUP BY u.id
HAVING COUNT(*) = 1;")->queryAll();
HAVING COUNT(*) = 1;")
->bindValue(1, $this->emailRepeatDelayDays)
->queryAll();

$this->logger->info(array_merge($logData, [
'users' => count($users)
Expand Down Expand Up @@ -837,13 +839,15 @@ public function sendPasswordExpiredEmails()
JOIN `password` p ON u.id = p.user_id
LEFT JOIN `email_log` e ON u.id = e.user_id
AND e.message_type = 'password-expired'
AND e.sent_utc >= CURRENT_DATE() - INTERVAL 31 DAY # EMAIL_REPEAT_DELAY_DAYS
AND e.sent_utc >= CURRENT_DATE() - INTERVAL ? DAY
WHERE u.active = 'yes'
AND u.locked = 'no'
AND p.expires_on <= CURRENT_DATE()
AND e.id IS NULL
GROUP BY u.id
HAVING COUNT(*) = 1;")->queryAll();
HAVING COUNT(*) = 1;")
->bindValue(1, $this->emailRepeatDelayDays)
->queryAll();

$this->logger->info(array_merge($logData, [
'users' => count($users)
Expand Down

0 comments on commit d145728

Please sign in to comment.