From 9db145495ec61a1c934b2ffa944543ecec442f0e Mon Sep 17 00:00:00 2001
From: vogelor <vogelor@ispconfig3>
Date: Sat, 01 May 2010 07:10:48 -0400
Subject: [PATCH] Fixed a error in cleaning the remote-actions - Table

---
 server/cron_daily.php |   12 ++++++++++--
 1 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/server/cron_daily.php b/server/cron_daily.php
index b5f7d1e..7299e9f 100644
--- a/server/cron_daily.php
+++ b/server/cron_daily.php
@@ -225,9 +225,17 @@
 	$app->dbmaster->query($sql);
 
 	/*
-	 *  Delete all remote-actions "done" and older than 7 days
+	 * Delete all remote-actions "done" and older than 7 days
+	 * ATTENTION: We have the same problem as described in cleaning the datalog. We must not
+	 * delete the last entry
 	 */
-	$sql = "DELETE FROM sys_remoteaction WHERE tstamp < " . $tstamp . " AND action_status = 'ok'";
+	$sql = "SELECT max(action_id) FROM sys_remoteaction";
+	$res = $app->dbmaster->queryOneRecord($sql);
+	$maxId = $res['max(action_id)'];
+	$sql =  "DELETE FROM sys_remoteaction " .
+			"WHERE tstamp < " . $tstamp . " " .
+			" AND action_status = 'ok' " .
+			" AND action_id <" . intval($maxId);
 	$app->dbmaster->query($sql);
 
 	/*

--
Gitblit v1.9.1