From 6b568bb8faf90a9402b6b5c7ffb68d2ebd1c6d6e Mon Sep 17 00:00:00 2001 From: Michael Date: Mon, 25 Jun 2018 20:23:32 +0000 Subject: [PATCH] Delete of item-content should work now --- database.sql | 3 ++- src/Database/DBStructure.php | 1 + src/Worker/Expire.php | 5 ++++- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/database.sql b/database.sql index cca1163145..9711ace803 100644 --- a/database.sql +++ b/database.sql @@ -541,7 +541,8 @@ CREATE TABLE IF NOT EXISTS `item` ( INDEX `contactid_verb` (`contact-id`,`verb`), INDEX `deleted_changed` (`deleted`,`changed`), INDEX `uid_wall_changed` (`uid`,`wall`,`changed`), - INDEX `uid_eventid` (`uid`,`event-id`) + INDEX `uid_eventid` (`uid`,`event-id`), + INDEX `icid` (`icid`) ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Structure for all posts'; -- diff --git a/src/Database/DBStructure.php b/src/Database/DBStructure.php index e6bbf22094..eaf54cee23 100644 --- a/src/Database/DBStructure.php +++ b/src/Database/DBStructure.php @@ -1248,6 +1248,7 @@ class DBStructure "deleted_changed" => ["deleted","changed"], "uid_wall_changed" => ["uid","wall","changed"], "uid_eventid" => ["uid","event-id"], + "icid" => ["icid"], ] ]; $database["item-content"] = [ diff --git a/src/Worker/Expire.php b/src/Worker/Expire.php index cf6e78cb72..713bfa25e0 100644 --- a/src/Worker/Expire.php +++ b/src/Worker/Expire.php @@ -26,9 +26,12 @@ 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` FROM `item` WHERE `deleted` AND `changed` < UTC_TIMESTAMP() - INTERVAL 60 DAY"); + $r = dba::p("SELECT `id`, `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']])) { + dba::delete('item-content', ['id' => $row['icid']]); + } } dba::close($r);