2018-08-25 17:48:50 -04:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* @file src/Worker/RemoveUser.php
|
2020-01-19 01:05:23 -05:00
|
|
|
* Removes orphaned data from deleted users
|
2018-08-25 17:48:50 -04:00
|
|
|
*/
|
|
|
|
namespace Friendica\Worker;
|
|
|
|
|
|
|
|
use Friendica\Database\DBA;
|
|
|
|
use Friendica\Model\Item;
|
|
|
|
|
|
|
|
class RemoveUser {
|
|
|
|
public static function execute($uid)
|
|
|
|
{
|
|
|
|
// Only delete if the user is archived
|
|
|
|
$condition = ['account_removed' => true, 'uid' => $uid];
|
|
|
|
if (!DBA::exists('user', $condition)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Now we delete all user items
|
2018-10-24 00:46:45 -04:00
|
|
|
$condition = ['uid' => $uid, 'deleted' => false];
|
|
|
|
do {
|
|
|
|
$items = Item::select(['id'], $condition, ['limit' => 100]);
|
|
|
|
while ($item = Item::fetch($items)) {
|
2018-11-12 00:03:12 -05:00
|
|
|
Item::deleteById($item['id'], PRIORITY_NEGLIGIBLE);
|
2018-10-24 00:46:45 -04:00
|
|
|
}
|
|
|
|
DBA::close($items);
|
|
|
|
} while (Item::exists($condition));
|
2018-08-25 17:48:50 -04:00
|
|
|
}
|
|
|
|
}
|