From 6f493f46b4db5705b618553a7dfe955783f145e4 Mon Sep 17 00:00:00 2001 From: azammitdcarf Date: Thu, 27 Sep 2012 01:01:02 +0000 Subject: [PATCH] Add process_clear_log function to make sure process_log table doesn't get too big --- admin/systemsortprocess.php | 2 ++ functions/functions.process.php | 29 +++++++++++++++++++++++++++++ functions/functions.voip.php | 4 ++++ 3 files changed, 35 insertions(+) diff --git a/admin/systemsortprocess.php b/admin/systemsortprocess.php index db37f4ce..5d7e042e 100644 --- a/admin/systemsortprocess.php +++ b/admin/systemsortprocess.php @@ -205,6 +205,8 @@ while (!is_process_killed($process_id)) //check if process killed every $sleepin if (is_process_killed($process_id)){break;} sleep($sleepinterval); } + + process_clear_log($process_id); } disable_systemsort(); diff --git a/functions/functions.process.php b/functions/functions.process.php index 5d251b21..9b8f0b85 100644 --- a/functions/functions.process.php +++ b/functions/functions.process.php @@ -246,4 +246,33 @@ function process_get_last_data($type = 1) return false; } + +/** + * Don't let the log get too big for this process + * + * @param int $process_id The process id + * + * @author Adam Zammit + * @since 2012-09-27 + */ +function process_clear_log($process_id) +{ + global $db; + + $sql = + "DELETE FROM process_log WHERE process_id = '$process_id' AND + process_log_id NOT IN ( + SELECT process_log_id + FROM ( + SELECT process_log_id + FROM process_log + WHERE process_id = '$process_id' + ORDER BY process_log_id DESC + LIMIT " . (PROCESS_LOG_LIMIT * 3) . " + ) x + )"; + + $db->Execute($sql); +} + ?> diff --git a/functions/functions.voip.php b/functions/functions.voip.php index 50f1df64..03e3ddb0 100644 --- a/functions/functions.voip.php +++ b/functions/functions.voip.php @@ -621,6 +621,10 @@ class voipWatch extends voip { $time = time(); } + if ($process_id) { + process_clear_log($process_id); + } + } while ($this->keepWatching); }