mirror of
https://github.com/friendica/friendica
synced 2024-11-10 11:42:54 +00:00
Remove items more memory friendly
This commit is contained in:
parent
7538dd2084
commit
c0a24d80dd
2 changed files with 18 additions and 1 deletions
|
@ -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]);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue