1
1
Fork 0

Remove items more memory friendly

This commit is contained in:
Michael 2018-10-24 04:46:45 +00:00
parent 7538dd2084
commit c0a24d80dd
2 changed files with 18 additions and 1 deletions

View file

@ -7,6 +7,7 @@ namespace Friendica\Worker;
use Friendica\Database\DBA;
use Friendica\Core\Protocol;
use Friendica\Model\Item;
require_once 'include/dba.php';
@ -21,6 +22,15 @@ class RemoveContact {
}
// Now we delete the contact and all depending tables
$condition = ['contact-id' => $id];
do {
$items = Item::select(['id'], $condition, ['limit' => 100]);
while ($item = Item::fetch($items)) {
DBA::delete('item', ['id' => $item['id']]);
}
DBA::close($items);
} while (Item::exists($condition));
DBA::delete('contact', ['id' => $id]);
}
}

View file

@ -20,6 +20,13 @@ class RemoveUser {
}
// Now we delete all user items
Item::delete(['uid' => $uid], PRIORITY_LOW);
$condition = ['uid' => $uid, 'deleted' => false];
do {
$items = Item::select(['id'], $condition, ['limit' => 100]);
while ($item = Item::fetch($items)) {
Item::deleteById($item['id'], PRIORITY_LOW);
}
DBA::close($items);
} while (Item::exists($condition));
}
}