--- /root/lib.php	2011-12-05 14:25:26.000000000 +0200
+++ lib.php	2011-12-05 13:26:20.000000000 +0200
@@ -257,7 +257,9 @@
         // but since mail isn't crucial, we can accept this risk.  Doing it now
         // prevents the risk of duplicated mails, which is a worse problem.
 
-        if (!forum_mark_old_posts_as_mailed($endtime)) {
+	// HACK atar++ 13:17 5/12/2011
+        //if (!forum_mark_old_posts_as_mailed($endtime)) {
+	if (!forum_mark_old_posts_as_mailed_hack($posts)) {
             mtrace('Errors occurred while trying to mark some posts as being mailed.');
             return false;  // Don't continue trying to mail them, in case we are in a cron loop
         }
@@ -2022,6 +2024,17 @@
     }
 }
 
+function forum_mark_old_posts_as_mailed_hack(&$posts) {
+    global $CFG;
+
+    $ids = join(',', array_keys($posts));
+
+    return execute_sql("UPDATE {$CFG->prefix}forum_posts
+                            SET mailed = '1'
+                        WHERE id IN ({$ids})
+                            AND mailed = 0", false);
+}
+
 /**
  * Get all the posts for a user in a forum suitable for forum_print_post
  */
