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