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

@ -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));
}
}