From 4388027c3798b40c073aca443fb658040dce3ad9 Mon Sep 17 00:00:00 2001 From: skodak Date: Tue, 9 Oct 2007 16:46:04 +0000 Subject: [PATCH] MDL-11674 fixed mysql incompatible SQL in chat cron --- mod/chat/lib.php | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/mod/chat/lib.php b/mod/chat/lib.php index d559949b2d..f802cb154e 100644 --- a/mod/chat/lib.php +++ b/mod/chat/lib.php @@ -233,14 +233,15 @@ function chat_cron () { chat_delete_old_users(); /// Delete old messages - $sql = "SELECT m.id - FROM {$CFG->prefix}chat_messages m - JOIN {$CFG->prefix}chat c - ON m.chatid = c.id - WHERE c.keepdays != 0 - AND m.timestamp < ( ".time()." - c.keepdays * 24 * 3600)"; - - delete_records_select("chat_messages", "id IN ($sql)"); + $keepdays = "SELECT c.keepdays + FROM {$CFG->prefix}chat c + WHERE c.id = {$CFG->prefix}chat_messages.chatid AND c.keepdays > 0"; + + $sql = "DELETE + FROM {$CFG->prefix}chat_messages + WHERE timestamp < ( ".time()." - COALESCE(($keepdays), 999999) * 24 * 3600)"; + + execute_sql($sql, false); return true; } -- 2.39.5