From 5fbba942de8ea384f601ed401d6bb929375aace8 Mon Sep 17 00:00:00 2001 From: Michael Date: Thu, 15 Aug 2024 04:17:14 +0000 Subject: [PATCH] Remove apcontact and diaspora-contact entries that aren't connected to contacts --- src/Worker/RemoveUnusedContacts.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/Worker/RemoveUnusedContacts.php b/src/Worker/RemoveUnusedContacts.php index f6d651cdb3..e95b0a0bf8 100644 --- a/src/Worker/RemoveUnusedContacts.php +++ b/src/Worker/RemoveUnusedContacts.php @@ -89,5 +89,13 @@ class RemoveUnusedContacts } DBA::close($contacts); Logger::notice('Removal done', ['count' => $count, 'total' => $total]); + + Logger::notice('Remove apcontact entries with no related contact'); + DBA::delete('apcontact', ["`uri-id` NOT IN (SELECT `uri-id` FROM `contact`) AND `updated` < ?", DateTimeFormat::utc('now - 30 days')]); + Logger::notice('Removed apcontact entries with no related contact', ['count' => DBA::affectedRows()]); + + Logger::notice('Remove diaspora-contact entries with no related contact'); + DBA::delete('diaspora-contact', ["`uri-id` NOT IN (SELECT `uri-id` FROM `contact`) AND `updated` < ?", DateTimeFormat::utc('now - 30 days')]); + Logger::notice('Removed diaspora-contact entries with no related contact', ['count' => DBA::affectedRows()]); } }