X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FWorker%2FRemoveContact.php;h=00027dca40a2e46dd2b78352a274885634ff0519;hb=82f713cb7fbc45f108e811a425c81c11c3b094d2;hp=40ac937f100ed4656a3ff251eecceea7aeb4bfbe;hpb=af6dbc654f82225cfc647fe2072662acae388e47;p=friendica.git diff --git a/src/Worker/RemoveContact.php b/src/Worker/RemoveContact.php index 40ac937f10..00027dca40 100644 --- a/src/Worker/RemoveContact.php +++ b/src/Worker/RemoveContact.php @@ -6,19 +6,29 @@ namespace Friendica\Worker; use Friendica\Database\DBA; - -require_once 'include/dba.php'; +use Friendica\Core\Protocol; +use Friendica\Model\Item; class RemoveContact { public static function execute($id) { - // Only delete if the contact doesn't exist (anymore) - $r = DBA::exists('contact', ['id' => $id]); - if ($r) { + // Only delete if the contact is to be deleted + $condition = ['network' => Protocol::PHANTOM, 'id' => $id]; + $contact = DBA::selectFirst('contact', ['uid'], $condition); + if (!DBA::isResult($contact)) { return; } - // Now we delete all the depending table entries + // Now we delete the contact and all depending tables + $condition = ['uid' => $contact['uid'], '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]); } }