From a94335c6ece9c3bf7c55823e40527abcba135ae1 Mon Sep 17 00:00:00 2001 From: Philipp Metzner Date: Tue, 16 Dec 2025 21:07:04 +0100 Subject: [PATCH 1/2] Set identical deleted and modified date in dailyroutine In some cases there might be an offset of 1sec. However it should have the same behavior as when deleting a beneficiary through the UI --- cron/dailyroutine.php | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/cron/dailyroutine.php b/cron/dailyroutine.php index 924e4354..36fc9486 100644 --- a/cron/dailyroutine.php +++ b/cron/dailyroutine.php @@ -48,9 +48,8 @@ $row['diff'] = $date2->diff($date1)->format('%a'); if ($row['diff'] > $row['treshold']) { - db_query('UPDATE people SET deleted = NOW() WHERE id = :id', ['id' => $row['id']]); + db_query('UPDATE people SET deleted = NOW(), modified = NOW(), modified_by = :user WHERE id = :id', ['user' => $_SESSION['user']['id'], 'id' => $row['id']]); simpleSaveChangeHistory('people', $row['id'], 'Record deleted by daily routine'); - db_touch('people', $row['id']); } } } @@ -61,9 +60,8 @@ FROM people AS p1, people AS p2 WHERE p2.parent_id = p1.id AND p1.deleted AND (NOT p2.deleted OR p2.deleted IS NULL)'); while ($row = db_fetch($result)) { - db_query('UPDATE people SET deleted = NOW() WHERE id = :id', ['id' => $row['id']]); + db_query('UPDATE people SET deleted = NOW(), modified = NOW(), modified_by = :user WHERE id = :id', ['user' => $_SESSION['user']['id'], 'id' => $row['id']]); simpleSaveChangeHistory('people', $row['id'], 'Record deleted by daily routine because head of family/beneficiary was deleted'); - db_touch('people', $row['id']); } // this notifies us when a new installation of the Drop App is made From c1e0a9b6ef1eed4aed0c9fd5cc6ce00d33dd009f Mon Sep 17 00:00:00 2001 From: Philipp Metzner Date: Tue, 16 Dec 2025 21:09:24 +0100 Subject: [PATCH 2/2] Remove unused function --- library/lib/database.php | 7 ------- 1 file changed, 7 deletions(-) diff --git a/library/lib/database.php b/library/lib/database.php index 613c1815..f9170b21 100644 --- a/library/lib/database.php +++ b/library/lib/database.php @@ -248,13 +248,6 @@ function db_tableexists($table, $dbid = false) return in_array($table, $tables); } -function db_touch($table, $id) -{ - if (db_fieldexists($table, 'modified')) { - db_query('UPDATE '.$table.' SET modified = NOW(), modified_by = :user WHERE id = :id', ['user' => $_SESSION['user']['id'], 'id' => $id]); - } -} - function db_simulate($query, $array = [], $dbid = false) { global $defaultdbid;