Merge pull request #6016 from annando/remove-data
Remove items more memory friendly
This commit is contained in:
commit
d6b31dad06
|
@ -17,10 +17,7 @@ use Friendica\Core\Config;
|
|||
use Friendica\Protocol\ActivityPub;
|
||||
|
||||
/**
|
||||
* ActivityPub Protocol class
|
||||
*
|
||||
* To-Do:
|
||||
* - Store Diaspora signature
|
||||
* ActivityPub Processor Protocol class
|
||||
*/
|
||||
class Processor
|
||||
{
|
||||
|
|
|
@ -39,9 +39,6 @@ require_once 'include/api.php';
|
|||
*
|
||||
* Complicated object types:
|
||||
* - Undo Announce
|
||||
*
|
||||
* General:
|
||||
* - Queueing unsucessful deliveries
|
||||
*/
|
||||
class Transmitter
|
||||
{
|
||||
|
|
|
@ -7,6 +7,7 @@ namespace Friendica\Worker;
|
|||
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\Core\Protocol;
|
||||
use Friendica\Model\Item;
|
||||
|
||||
require_once 'include/dba.php';
|
||||
|
||||
|
@ -15,12 +16,21 @@ class RemoveContact {
|
|||
|
||||
// Only delete if the contact is to be deleted
|
||||
$condition = ['network' => Protocol::PHANTOM, 'id' => $id];
|
||||
$r = DBA::exists('contact', $condition);
|
||||
if (!DBA::isResult($r)) {
|
||||
$contact = DBA::selectFirst('contact', ['uid'], $condition);
|
||||
if (!DBA::isResult($contact)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Now we delete the contact and all depending tables
|
||||
$condition = ['uid' => $contact['uid'], '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