Merge pull request #6016 from annando/remove-data

Remove items more memory friendly
pull/6024/head
Hypolite Petovan 2018-10-24 02:24:57 -04:00 zatwierdzone przez GitHub
commit d6b31dad06
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 4AEE18F83AFDEB23
4 zmienionych plików z 21 dodań i 10 usunięć

Wyświetl plik

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

Wyświetl plik

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

Wyświetl plik

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

Wyświetl plik

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