Delete the photo entries when a user or contact is removed

This commit is contained in:
Michael 2020-08-21 18:39:18 +00:00
parent cbdaf6298a
commit 7990d08ad6
2 changed files with 6 additions and 2 deletions

View file

@ -22,6 +22,7 @@
namespace Friendica\Worker;
use Friendica\Database\DBA;
use Friendica\Model\Photo;
use Friendica\Model\User;
/**
@ -51,6 +52,8 @@ class ExpireAndRemoveUsers
DBA::delete('contact', ['nurl' => $self['nurl'], 'self' => false]);
}
Photo::delete(['uid' => $user['uid']]);
DBA::delete('user', ['uid' => $user['uid']]);
}
DBA::close($users);

View 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;
}
@ -49,6 +49,7 @@ class RemoveContact {
DBA::close($items);
} while (Item::exists($condition));
Photo::delete(['uid' => $contact['uid'], 'contact-id' => $id]);
DBA::delete('contact', ['id' => $id]);
}
}