Previous Thread
Next Thread
Print Thread
Rate Thread
Joined: Jun 2017
Posts: 15
Newbie
Newbie
Offline
Joined: Jun 2017
Posts: 15
Problem:
Birthday emails were being sent multiple times per day due to a type mismatch and the lack of an immediate early exit, allowing re-processing even with a lock.

The following is log evidence from the admin log on our server of multiple birthday email batch runs. Each entry shows the time the process ran, who ran it, the number of emails sent, and the display names of the recipients. This is only a partial view. Some users have reported receiving as many as forty birthday emails. If you examine the lists of display names, you will see people being sent emails on multiple days as well. SaluteProducts, GucciVSbag1, 69 k20, lanebradford, GMC XLI, John Self, Wildman38, NCars, 1954trucker, Brittain, stylemaster47, mac_the_yankee, Brian Moore, Ian Ferguson, MoonDawg, JohnG 53, 1bigpig!, Bart, BenTolson, slotmandave, slick59, Fleetwoodfloyd, Hookalatch, Bobinpa, CaptKen47, noodlenose, sepp, tirediron
[Linked Image from stovebolt.com]
[Linked Image from stovebolt.com]
[Linked Image from stovebolt.com]

Note: the developer fixed a separate problem by ensuring that the value for birthday in {$config['TABLE_PREFIX']}CACHE was not erased when the cache was cleared. This was a necessary fix but did not completely resolve the issue

Solution:
  • Added early string exit if $sent === $today (lines 108-110) — prevents a re-run on same day.
  • Simplified lock claim query (lines 113-119) — removed redundant AND CACHE_VALUE = ? clause (original had unnecessary extra check; affected_rows suffices).
  • Added $sent_count tracking + optional debug log (lines 144, 153-154, 166-167) — counts emails and logs batch size.


Code Changes:

Early exit (added after globals - lines 104 & 105):

PHP
Code
// Quick exit if already done today
if ($sent === $today) {
    return;
}

Simplified lock claim (replaced original lines 115-120):

PHP
Code
$query = "
    UPDATE {$config['TABLE_PREFIX']}CACHE
    SET CACHE_VALUE = ?
    WHERE CACHE_FIELD = 'birthdays'
";
$dbh->do_placeholder_query($query, array("PENDING-$rightnow"), __LINE__, __FILE__);
Sent count + log (added in loop and after - added after line 165 - at the end of the function):

PHP
Code
  165     // Optional: log how many we sent (for debugging)
         if ($sent_count > 0) {
             admin_log("BIRTHDAY_BATCH", "Sent $sent_count birthday emails");
         }
This last one adds a line to the admin log that looks like this:
2026-01-02 18:00:37 UBB.threads (IP address) BIRTHDAY_BATCH Sent 27 birthday emails

Birthday emails should only be sent by UBB threads, not by user actions, and, if you incorporate this line, you should see one entry per day.


The Stovebolt Geek
https://www.stovebolt.com/ubbthreads/ubbthreads.php

Server Information
UBB.threads Version 8.0.0
Release 20240826
Server OS Linux
Server Load 0.11
Web Server Apache/2.4.37
PHP Version 8.3.11
MYSQL Version 8.0.39
Database Size 1.94 GB
Sponsored Links
Entire Thread
Subject Posted By Posted
Suggestion: Prevent duplicate birthday emails with sent flag stoveboltgeek 12/27/2025 8:50 PM
Re: Suggestion: Prevent duplicate birthday emails with sent flag stoveboltgeek 01/01/2026 7:08 AM
Re: Suggestion: Prevent duplicate birthday emails with sent flag stoveboltgeek 01/01/2026 7:00 PM
Re: Suggestion: Prevent duplicate birthday emails with sent flag stoveboltgeek 01/03/2026 8:55 PM

Link Copied to Clipboard
Donate Today!
Donate via PayPal

Donate to UBBDev today to help aid in Operational, Server and Script Maintenance, and Development costs.

Please also see our parent organization VNC Web Services if you're in the need of a new UBB.threads Install or Upgrade, Site/Server Migrations, or Security and Coding Services.
Recommended Hosts
We have personally worked with and recommend the following Web Hosts:
• Shock Hosting
• Stable Host
• bluehost
• InterServer
Visit us on Facebook
Member Spotlight
isaac
isaac
California
Posts: 1,156
Joined: July 2001
Forum Statistics
Forums63
Topics37,583
Posts293,957
Members13,826
Most Online151,614
Nov 14th, 2025
Today's Statistics
Currently Online 4330
Topics Created 0
Posts Made 0
Users Online 0
Birthdays 30
Top Posters
AllenAyres 21,080
JoshPet 10,369
LK 7,394
Lord Dexter 6,708
Gizmo 5,834
Greg Hard 4,625
Top Posters(30 Days)
isaac 2
Top Likes Received
isaac 82
Gizmo 20
Brett 7
Morgan 2
Top Likes Received (30 Days)
None yet
The UBB.Developers Network (UBB.Dev/Threads.Dev) is ©2000-2026 VNC Web Services

 
Powered by UBB.threads™ PHP Forum Software 8.1.0
(Snapshot build 20261026)