Merge pull request #5607 from annando/remove-contact
Remove contacts in the background
This commit is contained in:
commit
1ca8d573e6
2 changed files with 8 additions and 12 deletions
|
@ -314,15 +314,10 @@ class Contact extends BaseObject
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$archive = PConfig::get($contact['uid'], 'system', 'archive_removed_contacts');
|
// Archive the contact
|
||||||
if ($archive) {
|
DBA::update('contact', ['archive' => true, 'network' => Protocol::PHANTOM], ['id' => $id]);
|
||||||
DBA::update('contact', ['archive' => true, 'network' => 'none', 'writable' => false], ['id' => $id]);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
DBA::delete('contact', ['id' => $id]);
|
// Delete it in the background
|
||||||
|
|
||||||
// Delete the rest in the background
|
|
||||||
Worker::add(PRIORITY_LOW, 'RemoveContact', $id);
|
Worker::add(PRIORITY_LOW, 'RemoveContact', $id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -12,13 +12,14 @@ require_once 'include/dba.php';
|
||||||
class RemoveContact {
|
class RemoveContact {
|
||||||
public static function execute($id) {
|
public static function execute($id) {
|
||||||
|
|
||||||
// Only delete if the contact doesn't exist (anymore)
|
// Only delete if the contact is archived
|
||||||
$r = DBA::exists('contact', ['id' => $id]);
|
$condition = ['archive' => true, 'network' => Protocol::PHANTOM, 'id' => $id];
|
||||||
if ($r) {
|
$r = DBA::exists('contact', $condition);
|
||||||
|
if (!DBA::isResult($r)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Now we delete all the depending table entries
|
// Now we delete the contact and all depending tables
|
||||||
DBA::delete('contact', ['id' => $id]);
|
DBA::delete('contact', ['id' => $id]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue