]> git.mxchange.org Git - friendica.git/blobdiff - src/Worker/RemoveContact.php
Merge pull request #9044 from annando/avatar-stuff
[friendica.git] / src / Worker / RemoveContact.php
index 40e3a67fcf8fd933767c782868bcfa975b93b814..05771e2dc5c0ee5d1e494bcb5bfc552160df8711 100644 (file)
@@ -23,8 +23,8 @@ namespace Friendica\Worker;
 
 use Friendica\Core\Logger;
 use Friendica\Database\DBA;
-use Friendica\Core\Protocol;
 use Friendica\Model\Item;
+use Friendica\Model\Photo;
 
 /**
  * Removes orphaned data from deleted contacts
@@ -33,7 +33,7 @@ class RemoveContact {
        public static function execute($id) {
 
                // Only delete if the contact is to be deleted
-               $contact = DBA::selectFirst('contact', ['uid'], ['deleted' => true]);
+               $contact = DBA::selectFirst('contact', ['uid'], ['deleted' => true, 'id' => $id]);
                if (!DBA::isResult($contact)) {
                        return;
                }
@@ -41,14 +41,15 @@ class RemoveContact {
                // Now we delete the contact and all depending tables
                $condition = ['uid' => $contact['uid'], 'contact-id' => $id];
                do {
-                       $items = Item::select(['id'], $condition, ['limit' => 100]);
+                       $items = Item::select(['id', 'guid'], $condition, ['limit' => 100]);
                        while ($item = Item::fetch($items)) {
-                               Logger::notice('Delete removed contact item', ['id' => $item["id"]]);
+                               Logger::info('Delete removed contact item', ['id' => $item['id'], 'guid' => $item['guid']]);
                                DBA::delete('item', ['id' => $item['id']]);
                        }
                        DBA::close($items);
                } while (Item::exists($condition));
 
+               Photo::delete(['uid' => $contact['uid'], 'contact-id' => $id]);
                DBA::delete('contact', ['id' => $id]);
        }
 }