Merge pull request #6016 from annando/remove-data

Remove items more memory friendly
This commit is contained in:
Hypolite Petovan 2018-10-24 02:24:57 -04:00 committed by GitHub
commit d6b31dad06
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 21 additions and 10 deletions

View file

@ -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
{

View file

@ -39,9 +39,6 @@ require_once 'include/api.php';
*
* Complicated object types:
* - Undo Announce
*
* General:
* - Queueing unsucessful deliveries
*/
class Transmitter
{

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

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