"Abandoned Session Interval" ignores the server timezone

  • Pablo
  • Pablo's Avatar Topic Author
  • Offline
  • Senior Member
  • Senior Member
More
3 days 22 hours ago #1 by Pablo
Hi,I found a timezone problem in the abandoned-session check of
Code:
SendingModel::send()
. It may affect other users who send newsletters in batches.

Version: NS Pro 4.1.3350 (Joomla 5/6)SymptomWhen a sending process dies without writing
Code:
end_sending_session
(for example, a killed PHP process on a managed host), the newsletter stays locked. Every cron run then logs
Code:
previous_session_still_active
until NS Pro decides the session was abandoned. In my case, with Abandoned Session Interval set to 15 minutes, sending only resumed after about 85 minutes.CauseLog rows are written with the PHP server time: php
Code:
InsertSendingLog(..., date('Y-m-d H:i:s'), ...);
But the abandoned check (
Code:
administrator/components/com_nspro/src/Model/SendingModel.php
, line 185) compares that value against the current time in UTC: php
Code:
TIMESTAMPDIFF(MINUTE, `datetime`, "'.$db->escape(HTMLHelper::date('now', 'Y-m-d H:i:s', 'UTC')).'") > '.intval($abandoned_interval)
So the elapsed time is off by the server's UTC offset. I confirmed it on my site: sql
Code:
SELECT MAX(datetime) AS last_log, UTC_TIMESTAMP() AS utc_now FROM #__nspro_newsletter_sending_log; -- last_log: 2026-11-10 20:25:03 | utc_now: 2026-11-10 19:25:09
My server runs on Europe/Madrid (UTC+1), so the effective interval was 15 + 60 = 75 minutes, plus up to one cron interval. That matches the 85 minutes I observed.The effect depends on the offset:
  • Servers ahead of UTC (Europe, Asia): orphaned sessions are released late, by the amount of the offset.
  • Servers behind UTC (Americas): the computed elapsed time is too large. A session could be treated as abandoned immediately, so a second process could start while the first one is still sending, which risks duplicate emails.
Suggested fixCompare against the same clock the log uses. One-line change at line 185: diff
Code:
- ... "'.$db->escape(HTMLHelper::date('now', 'Y-m-d H:i:s', 'UTC')).'") ... + ... "'.$db->escape(date('Y-m-d H:i:s')).'") ...
Alternatively, write the log
Code:
datetime
in UTC as well, so both sides are consistent. I only checked this one place:
Code:
ref_time
and the scheduling logic compare UTC with UTC, so they look consistent.Could you include a fix in a future release?Thanks,
Pablo

Please Log in or Create an account to join the conversation.

  • Christopher Mavros
  • Christopher Mavros's Avatar
  • Offline
  • Administrator
  • Administrator
More
3 days 5 hours ago #2 by Christopher Mavros
Replied by Christopher Mavros on topic "Abandoned Session Interval" ignores the server timezone
Hello Pablo and thank you very much for bringing this to my attention.

You're right: the log is written with the server's clock and compared against UTC.

I fixed it and included the fix in the version that will be released today.

I preferred to switch the check to date() rather than update the existing logs and affect how they're written.
As you pointed out, servers behind UTC were the more serious case.
After the update, it will work correctly for every time zone.

Christopher Mavros
me@mavxr.com
If you like our extensions, please review in the Joomla Extension Directory!

Please Log in or Create an account to join the conversation.

Moderators: Christopher Mavros
Ask me!