Friendica Communications Platform
(please note that this is a clone of the repository at github, issues are handled there)
https://friendi.ca
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
30 lines
727 B
30 lines
727 B
<?php |
|
/** |
|
* @file src/Worker/RemoveUser.php |
|
* @brief Removes orphaned data from deleted users |
|
*/ |
|
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 |
|
$condition = ['uid' => $uid, 'deleted' => false]; |
|
do { |
|
$items = Item::select(['id'], $condition, ['limit' => 100]); |
|
while ($item = Item::fetch($items)) { |
|
Item::deleteById($item['id'], PRIORITY_NEGLIGIBLE); |
|
} |
|
DBA::close($items); |
|
} while (Item::exists($condition)); |
|
} |
|
}
|
|
|