X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FWorker%2FRemoveContact.php;h=00027dca40a2e46dd2b78352a274885634ff0519;hb=cbe2d1745ba327464f260efd7d782c383994a285;hp=8f986eab11559c18630315429dd783910dfa9205;hpb=4ae37c61966a7f4c055369ee8fd0d4bc20808fdb;p=friendica.git diff --git a/src/Worker/RemoveContact.php b/src/Worker/RemoveContact.php index 8f986eab11..00027dca40 100644 --- a/src/Worker/RemoveContact.php +++ b/src/Worker/RemoveContact.php @@ -7,20 +7,28 @@ namespace Friendica\Worker; use Friendica\Database\DBA; use Friendica\Core\Protocol; - -require_once 'include/dba.php'; +use Friendica\Model\Item; class RemoveContact { public static function execute($id) { // 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 = ['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]); } }