mirror of
https://github.com/friendica/friendica
synced 2025-04-27 08:30:10 +00:00
Delete removed contacts
This commit is contained in:
parent
cb5362f499
commit
a331a8cf0a
7 changed files with 59 additions and 15 deletions
|
@ -31,15 +31,21 @@ use Friendica\Model\Photo;
|
|||
*/
|
||||
class RemoveContact {
|
||||
public static function execute($id) {
|
||||
|
||||
// Only delete if the contact is to be deleted
|
||||
$contact = DBA::selectFirst('contact', ['uid'], ['deleted' => true, 'id' => $id]);
|
||||
if (!DBA::isResult($contact)) {
|
||||
return;
|
||||
}
|
||||
|
||||
Logger::info('Start deleting contact', ['id' => $id]);
|
||||
// Now we delete the contact and all depending tables
|
||||
$condition = ['uid' => $contact['uid'], 'contact-id' => $id];
|
||||
if ($contact['uid'] == 0) {
|
||||
DBA::delete('post-tag', ['cid' => $id]);
|
||||
$condition = ["`author-id` = ? OR `owner-id` = ? OR `causer-id` = ? OR `contact-id` = ?",
|
||||
$id, $id, $id, $id];
|
||||
} else {
|
||||
$condition = ['uid' => $contact['uid'], 'contact-id' => $id];
|
||||
}
|
||||
do {
|
||||
$items = Item::select(['id', 'guid'], $condition, ['limit' => 100]);
|
||||
while ($item = Item::fetch($items)) {
|
||||
|
@ -49,7 +55,8 @@ class RemoveContact {
|
|||
DBA::close($items);
|
||||
} while (Item::exists($condition));
|
||||
|
||||
Photo::delete(['uid' => $contact['uid'], 'contact-id' => $id]);
|
||||
DBA::delete('contact', ['id' => $id]);
|
||||
Photo::delete(['contact-id' => $id]);
|
||||
$ret = DBA::delete('contact', ['id' => $id]);
|
||||
Logger::info('Deleted contact', ['id' => $id, 'result' => $ret]);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue