Skip to content

Commit 9db1454

Browse files
author
vogelor
committed
Fixed a error in cleaning the remote-actions - Table
1 parent 45841f0 commit 9db1454

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

server/cron_daily.php

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -225,9 +225,17 @@ function setConfigVar( $filename, $varName, $varValue ) {
225225
$app->dbmaster->query($sql);
226226

227227
/*
228-
* Delete all remote-actions "done" and older than 7 days
228+
* Delete all remote-actions "done" and older than 7 days
229+
* ATTENTION: We have the same problem as described in cleaning the datalog. We must not
230+
* delete the last entry
229231
*/
230-
$sql = "DELETE FROM sys_remoteaction WHERE tstamp < " . $tstamp . " AND action_status = 'ok'";
232+
$sql = "SELECT max(action_id) FROM sys_remoteaction";
233+
$res = $app->dbmaster->queryOneRecord($sql);
234+
$maxId = $res['max(action_id)'];
235+
$sql = "DELETE FROM sys_remoteaction " .
236+
"WHERE tstamp < " . $tstamp . " " .
237+
" AND action_status = 'ok' " .
238+
" AND action_id <" . intval($maxId);
231239
$app->dbmaster->query($sql);
232240

233241
/*

0 commit comments

Comments
 (0)