Merge pull request #9946 from annando/delete-contacts
Contacts are now removed more ressource friendly
This commit is contained in:
commit
d2360d14ed
1 changed files with 13 additions and 21 deletions
|
@ -37,35 +37,23 @@ class RemoveContact {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Only delete if the contact is to be deleted
|
// Only delete if the contact is to be deleted
|
||||||
$contact = DBA::selectFirst('contact', ['uid'], ['deleted' => true, 'id' => $id]);
|
$contact = DBA::selectFirst('contact', ['id', 'uid', 'url', 'nick', 'name'], ['deleted' => true, 'id' => $id]);
|
||||||
if (!DBA::isResult($contact)) {
|
if (!DBA::isResult($contact)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Logger::info('Start deleting contact', ['id' => $id]);
|
Logger::info('Start deleting contact', ['contact' => $contact]);
|
||||||
|
|
||||||
// Now we delete the contact and all depending tables
|
// Now we delete the contact and all depending tables
|
||||||
if ($contact['uid'] == 0) {
|
DBA::delete('post-tag', ['cid' => $id]);
|
||||||
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];
|
|
||||||
}
|
|
||||||
if (DBStructure::existsTable('item')) {
|
if (DBStructure::existsTable('item')) {
|
||||||
do {
|
DBA::delete('item', ['author-id' => $id]);
|
||||||
$items = Post::select(['uri-id', 'guid', 'uid'], $condition, ['limit' => 100]);
|
DBA::delete('item', ['owner-id' => $id]);
|
||||||
while ($item = Post::fetch($items)) {
|
DBA::delete('item', ['causer-id' => $id]);
|
||||||
Logger::info('Delete removed contact item', ['uri-id' => $item['uri-id'], 'uid', 'guid' => $item['guid']]);
|
DBA::delete('item', ['contact-id' => $id]);
|
||||||
DBA::delete('item', ['uri-id' => $item['uri-id'], 'uid' => $item['uid']]);
|
|
||||||
}
|
|
||||||
DBA::close($items);
|
|
||||||
} while (Post::exists($condition));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Post\User::delete(['author-id' => $id]);
|
|
||||||
Post\User::delete(['owner-id' => $id]);
|
|
||||||
Post\User::delete(['causer-id' => $id]);
|
|
||||||
Post\User::delete(['contact-id' => $id]);
|
|
||||||
Post\ThreadUser::delete(['author-id' => $id]);
|
Post\ThreadUser::delete(['author-id' => $id]);
|
||||||
Post\ThreadUser::delete(['owner-id' => $id]);
|
Post\ThreadUser::delete(['owner-id' => $id]);
|
||||||
Post\ThreadUser::delete(['causer-id' => $id]);
|
Post\ThreadUser::delete(['causer-id' => $id]);
|
||||||
|
@ -73,6 +61,10 @@ class RemoveContact {
|
||||||
Post\Thread::delete(['author-id' => $id]);
|
Post\Thread::delete(['author-id' => $id]);
|
||||||
Post\Thread::delete(['owner-id' => $id]);
|
Post\Thread::delete(['owner-id' => $id]);
|
||||||
Post\Thread::delete(['causer-id' => $id]);
|
Post\Thread::delete(['causer-id' => $id]);
|
||||||
|
Post\User::delete(['author-id' => $id]);
|
||||||
|
Post\User::delete(['owner-id' => $id]);
|
||||||
|
Post\User::delete(['causer-id' => $id]);
|
||||||
|
Post\User::delete(['contact-id' => $id]);
|
||||||
Post::delete(['author-id' => $id]);
|
Post::delete(['author-id' => $id]);
|
||||||
Post::delete(['owner-id' => $id]);
|
Post::delete(['owner-id' => $id]);
|
||||||
Post::delete(['causer-id' => $id]);
|
Post::delete(['causer-id' => $id]);
|
||||||
|
|
Loading…
Reference in a new issue