--- notify-5.x-1.2/notify.module 2009-01-13 17:10:53.000000000 -0800 +++ /home/Web/sites/all/modules/notify/notify.module 2009-02-02 13:18:15.000000000 -0800 @@ -71,12 +71,13 @@ function notify_cron() { $send_last = variable_get('notify_send_last', 0); $send_interval = variable_get('notify_send', 86400); $send_hour = variable_get('notify_send_hour', date('G', variable_get('notify_send_last', 0))); - if ( (time() - $send_last > $send_interval) - && (date('G', time()) > $send_hour) + variable_set('notify_send_start', $send_start = time()); + if ( ($send_start - $send_last > $send_interval) + && (date('G', $send_start) > $send_hour) && ($send_interval != -1) //special case of settings to send 'never' ) { _notify_send(); - variable_set('notify_send_last', time()); + variable_set('notify_send_last', $send_start); } } @@ -256,8 +257,9 @@ function notify_admin_users_submit($form drupal_set_message(t('Notify settings saved.')); if ($form_values['flush']) { + variable_set('notify_send_start', $send_start = time()); list($num_sent, $num_failed) = _notify_send(); - variable_set('notify_send_last', time()); + variable_set('notify_send_last', $send_start); if ($num_sent > 0) { drupal_set_message(t('!count pending notification e-mails have been sent.', array('!count' => $num_sent))); @@ -351,7 +353,8 @@ function _notify_content_html ($node, $n * TODO: Needs some cleanup and themability. */ function _notify_send() { - $period = variable_get('notify_send_last', time() - variable_get('notify_send', 86400)); + $now = variable_get('notify_send_start', time()); + $period = variable_get('notify_send_last', $now - variable_get('notify_send', 86400)); $separator = '------------------------------------------------------------------------------'; $mini_separator = '---'; @@ -368,14 +371,14 @@ function _notify_send() { _notify_switch_user($user->uid); // Fetch all new nodes and 'load' it to get proper body, etc. - $nresult = db_query(db_rewrite_sql('SELECT n.nid FROM {node} n WHERE (n.status = 1 OR n.moderate = 1) AND n.created > %d AND n.created <= %d ORDER BY n.created'), $period, time()); + $nresult = db_query(db_rewrite_sql('SELECT n.nid FROM {node} n WHERE (n.status = 1 OR n.moderate = 1) AND n.created > %d AND n.created <= %d ORDER BY n.created'), $period, $now); $nodes = array(); while ($node = db_fetch_object($nresult)) { $nodes[$node->nid] = node_load($node->nid); } // Fetch new comments. - $cresult = db_query(db_rewrite_sql('SELECT c.nid, c.cid, c.subject, c.name FROM {comments} c WHERE c.status = %d AND c.timestamp > %d AND c.timestamp <= %d ORDER BY c.nid, c.timestamp', 'c'), COMMENT_PUBLISHED, $period, time()); + $cresult = db_query(db_rewrite_sql('SELECT c.nid, c.cid, c.subject, c.name FROM {comments} c WHERE c.status = %d AND c.timestamp > %d AND c.timestamp <= %d ORDER BY c.nid, c.timestamp', 'c'), COMMENT_PUBLISHED, $period, $now); $comments = array(); while ($comment = db_fetch_object($cresult)) { $comments[$comment->nid][] = $comment;