From c944af8239029635dc51218aca722db29560bd7a Mon Sep 17 00:00:00 2001 From: Ashley Holman Date: Wed, 20 May 2009 16:51:47 +0930 Subject: [PATCH] Forum cron: update digestmailtimelast in db BEFORE starting to send digest emails This fixes the "duplicate digest" bug where multiple copies of the digest emails are received if the sending isn't finished before the next cron process starts. --- mod/forum/lib.php | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/mod/forum/lib.php b/mod/forum/lib.php index 9c89eae..d80cdd2 100644 --- a/mod/forum/lib.php +++ b/mod/forum/lib.php @@ -536,6 +536,8 @@ function forum_cron() { $digestposts_rs = get_recordset_select('forum_queue', "timemodified < $digesttime"); + // update 'digestmailtimelast' in the DB now to prevent other cron processes starting the digest process before we finish + set_config('digestmailtimelast', $timenow); if (!rs_EOF($digestposts_rs)) { // We have work to do @@ -770,8 +772,6 @@ function forum_cron() { } } } - /// We have finishied all digest emails, update $CFG->digestmailtimelast - set_config('digestmailtimelast', $timenow); } $USER = $cronuser; -- 1.6.0.6