Ensure that deleted contacts are really removed

This commit is contained in:
Michael 2020-01-11 17:22:37 +00:00
parent a5895f8623
commit 0225e99d0a
2 changed files with 16 additions and 2 deletions

View file

@ -84,6 +84,8 @@ class Cron
// check upstream version? // check upstream version?
Worker::add(PRIORITY_LOW, 'CheckVersion'); Worker::add(PRIORITY_LOW, 'CheckVersion');
self::checkdeletedContacts();
Config::set('system', 'last_expire_day', $d2); Config::set('system', 'last_expire_day', $d2);
} }
@ -121,6 +123,19 @@ class Cron
return; return;
} }
/**
* Checks for contacts that are about to be deleted and ensures that they are removed.
* This should be done automatically in the "remove" function. This here is a cleanup job.
*/
private static function checkdeletedContacts()
{
$contacts = DBA::select('contact', ['id'], ['deleted' => true]);
while ($contact = DBA::fetch($contacts)) {
Worker::add(PRIORITY_MEDIUM, 'RemoveContact', $contact['id']);
}
DBA::close($contacts);
}
/** /**
* @brief Update public contacts * @brief Update public contacts
* @throws \Friendica\Network\HTTPException\InternalServerErrorException * @throws \Friendica\Network\HTTPException\InternalServerErrorException

View file

@ -13,8 +13,7 @@ class RemoveContact {
public static function execute($id) { public static function execute($id) {
// Only delete if the contact is to be deleted // Only delete if the contact is to be deleted
$condition = ['network' => Protocol::PHANTOM, 'id' => $id]; $contact = DBA::selectFirst('contact', ['uid'], ['deleted' => true]);
$contact = DBA::selectFirst('contact', ['uid'], $condition);
if (!DBA::isResult($contact)) { if (!DBA::isResult($contact)) {
return; return;
} }