Merge pull request #5607 from annando/remove-contact

Remove contacts in the background
pull/5611/head
Tobias Diekershoff 2018-08-13 06:42:08 +02:00 zatwierdzone przez GitHub
commit 1ca8d573e6
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 4AEE18F83AFDEB23
2 zmienionych plików z 8 dodań i 12 usunięć

Wyświetl plik

@ -314,15 +314,10 @@ class Contact extends BaseObject
return;
}
$archive = PConfig::get($contact['uid'], 'system', 'archive_removed_contacts');
if ($archive) {
DBA::update('contact', ['archive' => true, 'network' => 'none', 'writable' => false], ['id' => $id]);
return;
}
// Archive the contact
DBA::update('contact', ['archive' => true, 'network' => Protocol::PHANTOM], ['id' => $id]);
DBA::delete('contact', ['id' => $id]);
// Delete the rest in the background
// Delete it in the background
Worker::add(PRIORITY_LOW, 'RemoveContact', $id);
}

Wyświetl plik

@ -12,13 +12,14 @@ require_once 'include/dba.php';
class RemoveContact {
public static function execute($id) {
// Only delete if the contact doesn't exist (anymore)
$r = DBA::exists('contact', ['id' => $id]);
if ($r) {
// Only delete if the contact is archived
$condition = ['archive' => true, 'network' => Protocol::PHANTOM, 'id' => $id];
$r = DBA::exists('contact', $condition);
if (!DBA::isResult($r)) {
return;
}
// Now we delete all the depending table entries
// Now we delete the contact and all depending tables
DBA::delete('contact', ['id' => $id]);
}
}