From 014eea8e1222c38677fdbd1fdcc8634e35aa25b0 Mon Sep 17 00:00:00 2001 From: Michael Date: Thu, 5 Jul 2018 22:07:50 +0000 Subject: [PATCH] Improve expire for item-content and item-activity --- src/Model/Item.php | 4 ++++ src/Worker/Expire.php | 7 +++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/Model/Item.php b/src/Model/Item.php index b6af5e7d9d..1382e5217e 100644 --- a/src/Model/Item.php +++ b/src/Model/Item.php @@ -766,6 +766,10 @@ class Item extends BaseObject dba::update('item', $item_fields, ['id' => $item['id']]); } } + } else { + if (empty($item['iaid'])) { + // To-Do + } } if (!empty($tags)) { diff --git a/src/Worker/Expire.php b/src/Worker/Expire.php index 713bfa25e0..342408894e 100644 --- a/src/Worker/Expire.php +++ b/src/Worker/Expire.php @@ -26,10 +26,13 @@ class Expire { if ($param == 'delete') { logger('Delete expired items', LOGGER_DEBUG); // physically remove anything that has been deleted for more than two months - $r = dba::p("SELECT `id`, `icid` FROM `item` WHERE `deleted` AND `changed` < UTC_TIMESTAMP() - INTERVAL 60 DAY"); + $r = dba::p("SELECT `id`, `iaid`, `icid` FROM `item` WHERE `deleted` AND `changed` < UTC_TIMESTAMP() - INTERVAL 60 DAY"); while ($row = dba::fetch($r)) { dba::delete('item', ['id' => $row['id']]); - if (!dba::exists('item', ['icid' => $row['icid']])) { + if (!empty($row['iaid']) && !dba::exists('item', ['iaid' => $row['iaid']])) { + dba::delete('item-content', ['id' => $row['icid']]); + } + if (!empty($row['icid']) && !dba::exists('item', ['icid' => $row['icid']])) { dba::delete('item-content', ['id' => $row['icid']]); } }