From: skodak Date: Tue, 9 Oct 2007 16:46:04 +0000 (+0000) Subject: MDL-11674 fixed mysql incompatible SQL in chat cron X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=4388027c3798b40c073aca443fb658040dce3ad9;p=moodle.git MDL-11674 fixed mysql incompatible SQL in chat cron --- 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; }