3 * @file src/Worker/RemoveContact.php
4 * Removes orphaned data from deleted contacts
6 namespace Friendica\Worker;
8 use Friendica\Database\DBA;
9 use Friendica\Core\Protocol;
10 use Friendica\Model\Item;
13 public static function execute($id) {
15 // Only delete if the contact is to be deleted
16 $contact = DBA::selectFirst('contact', ['uid'], ['deleted' => true]);
17 if (!DBA::isResult($contact)) {
21 // Now we delete the contact and all depending tables
22 $condition = ['uid' => $contact['uid'], 'contact-id' => $id];
24 $items = Item::select(['id'], $condition, ['limit' => 100]);
25 while ($item = Item::fetch($items)) {
26 DBA::delete('item', ['id' => $item['id']]);
29 } while (Item::exists($condition));
31 DBA::delete('contact', ['id' => $id]);