X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FWorker%2FRemoveUnusedContacts.php;h=038376c22c925d199edca8d6d49ec13b905e63fe;hb=38cf0666bd7a6537a5a6af19b5bd6073ef12e82f;hp=a781a490a2c53fd87121e756b0c0266ce4f37fcc;hpb=9e1f03ca11ec5efc48c6f503ce16ea5df39c59af;p=friendica.git diff --git a/src/Worker/RemoveUnusedContacts.php b/src/Worker/RemoveUnusedContacts.php index a781a490a2..038376c22c 100644 --- a/src/Worker/RemoveUnusedContacts.php +++ b/src/Worker/RemoveUnusedContacts.php @@ -1,6 +1,6 @@ $total]); $count = 0; - $contacts = DBA::select('contact', ['id', 'uid'], $condition); + $contacts = DBA::select('contact', ['id', 'uid', 'photo', 'thumb', 'micro'], $condition); while ($contact = DBA::fetch($contacts)) { - if (Photo::delete(['uid' => $contact['uid'], 'contact-id' => $contact['id']])) { - if (DBStructure::existsTable('thread')) { - DBA::delete('thread', ['owner-id' => $contact['id']]); - DBA::delete('thread', ['author-id' => $contact['id']]); - } - if (DBStructure::existsTable('item')) { - DBA::delete('item', ['owner-id' => $contact['id']]); - DBA::delete('item', ['author-id' => $contact['id']]); - DBA::delete('item', ['causer-id' => $contact['id']]); - } + Photo::delete(['uid' => $contact['uid'], 'contact-id' => $contact['id']]); + Avatar::deleteCache($contact); - // There should be none entry for the contact in these tables when none was found in "post-user". - // But we want to be sure since the foreign key prohibits deletion otherwise. - DBA::delete('post', ['owner-id' => $contact['id']]); - DBA::delete('post', ['author-id' => $contact['id']]); - DBA::delete('post', ['causer-id' => $contact['id']]); - - DBA::delete('post-thread', ['owner-id' => $contact['id']]); - DBA::delete('post-thread', ['author-id' => $contact['id']]); - DBA::delete('post-thread', ['causer-id' => $contact['id']]); + if (DBStructure::existsTable('thread')) { + DBA::delete('thread', ['owner-id' => $contact['id']]); + DBA::delete('thread', ['author-id' => $contact['id']]); + } + if (DBStructure::existsTable('item')) { + DBA::delete('item', ['owner-id' => $contact['id']]); + DBA::delete('item', ['author-id' => $contact['id']]); + DBA::delete('item', ['causer-id' => $contact['id']]); + } + + // There should be none entry for the contact in these tables when none was found in "post-user". + // But we want to be sure since the foreign key prohibits deletion otherwise. + DBA::delete('post', ['owner-id' => $contact['id']]); + DBA::delete('post', ['author-id' => $contact['id']]); + DBA::delete('post', ['causer-id' => $contact['id']]); + + DBA::delete('post-thread', ['owner-id' => $contact['id']]); + DBA::delete('post-thread', ['author-id' => $contact['id']]); + DBA::delete('post-thread', ['causer-id' => $contact['id']]); - DBA::delete('post-thread-user', ['owner-id' => $contact['id']]); - DBA::delete('post-thread-user', ['author-id' => $contact['id']]); - DBA::delete('post-thread-user', ['causer-id' => $contact['id']]); + DBA::delete('post-thread-user', ['owner-id' => $contact['id']]); + DBA::delete('post-thread-user', ['author-id' => $contact['id']]); + DBA::delete('post-thread-user', ['causer-id' => $contact['id']]); - DBA::delete('contact', ['id' => $contact['id']]); - if ((++$count % 1000) == 0) { - Logger::notice('In removal', ['count' => $count, 'total' => $total]); - } + Contact::deleteById($contact['id']); + if ((++$count % 1000) == 0) { + Logger::info('In removal', ['count' => $count, 'total' => $total]); } } DBA::close($contacts);