From c0a24d80dda2dccf44579b1ae0ddba87abead658 Mon Sep 17 00:00:00 2001 From: Michael Date: Wed, 24 Oct 2018 04:46:45 +0000 Subject: [PATCH 1/3] Remove items more memory friendly --- src/Worker/RemoveContact.php | 10 ++++++++++ src/Worker/RemoveUser.php | 9 ++++++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/src/Worker/RemoveContact.php b/src/Worker/RemoveContact.php index 8f986eab1..8485adda6 100644 --- a/src/Worker/RemoveContact.php +++ b/src/Worker/RemoveContact.php @@ -7,6 +7,7 @@ namespace Friendica\Worker; use Friendica\Database\DBA; use Friendica\Core\Protocol; +use Friendica\Model\Item; require_once 'include/dba.php'; @@ -21,6 +22,15 @@ class RemoveContact { } // Now we delete the contact and all depending tables + $condition = ['contact-id' => $id]; + do { + $items = Item::select(['id'], $condition, ['limit' => 100]); + while ($item = Item::fetch($items)) { + DBA::delete('item', ['id' => $item['id']]); + } + DBA::close($items); + } while (Item::exists($condition)); + DBA::delete('contact', ['id' => $id]); } } diff --git a/src/Worker/RemoveUser.php b/src/Worker/RemoveUser.php index dfa5ccc09..d8966e5a4 100644 --- a/src/Worker/RemoveUser.php +++ b/src/Worker/RemoveUser.php @@ -20,6 +20,13 @@ class RemoveUser { } // Now we delete all user items - Item::delete(['uid' => $uid], PRIORITY_LOW); + $condition = ['uid' => $uid, 'deleted' => false]; + do { + $items = Item::select(['id'], $condition, ['limit' => 100]); + while ($item = Item::fetch($items)) { + Item::deleteById($item['id'], PRIORITY_LOW); + } + DBA::close($items); + } while (Item::exists($condition)); } } From a6f6db8d4ec9406b93689aaf4a1da2e2524e42c9 Mon Sep 17 00:00:00 2001 From: Michael Date: Wed, 24 Oct 2018 04:50:27 +0000 Subject: [PATCH 2/3] Improve query speed --- src/Worker/RemoveContact.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Worker/RemoveContact.php b/src/Worker/RemoveContact.php index 8485adda6..2e3f16db3 100644 --- a/src/Worker/RemoveContact.php +++ b/src/Worker/RemoveContact.php @@ -16,13 +16,13 @@ class RemoveContact { // Only delete if the contact is to be deleted $condition = ['network' => Protocol::PHANTOM, 'id' => $id]; - $r = DBA::exists('contact', $condition); - if (!DBA::isResult($r)) { + $contact = DBA::selectFirst('contact', ['uid'], $condition); + if (!DBA::isResult($contact)) { return; } // Now we delete the contact and all depending tables - $condition = ['contact-id' => $id]; + $condition = ['uid' => $contact['uid'], 'contact-id' => $id]; do { $items = Item::select(['id'], $condition, ['limit' => 100]); while ($item = Item::fetch($items)) { From c25d60e107cd4d067ba3107cb8d623a76d5bdf81 Mon Sep 17 00:00:00 2001 From: Michael Date: Wed, 24 Oct 2018 04:51:37 +0000 Subject: [PATCH 3/3] Removed finished work from the comments --- src/Protocol/ActivityPub/Processor.php | 5 +---- src/Protocol/ActivityPub/Transmitter.php | 3 --- 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/src/Protocol/ActivityPub/Processor.php b/src/Protocol/ActivityPub/Processor.php index 9bafb5e17..8a80bd2be 100644 --- a/src/Protocol/ActivityPub/Processor.php +++ b/src/Protocol/ActivityPub/Processor.php @@ -17,10 +17,7 @@ use Friendica\Core\Config; use Friendica\Protocol\ActivityPub; /** - * ActivityPub Protocol class - * - * To-Do: - * - Store Diaspora signature + * ActivityPub Processor Protocol class */ class Processor { diff --git a/src/Protocol/ActivityPub/Transmitter.php b/src/Protocol/ActivityPub/Transmitter.php index a37d03537..b0e6cd362 100644 --- a/src/Protocol/ActivityPub/Transmitter.php +++ b/src/Protocol/ActivityPub/Transmitter.php @@ -39,9 +39,6 @@ require_once 'include/api.php'; * * Complicated object types: * - Undo Announce - * - * General: - * - Queueing unsucessful deliveries */ class Transmitter {