X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FWorker%2FRemoveUser.php;h=72ead5264292c7c543df91aee66ef69af83e9df8;hb=39607b20e2973fb271544b69b3594d5a56b547c8;hp=dfa5ccc097c7e9ea14c2c6f66d8488e22ab2e710;hpb=31d47ade784c080e15626305e7cc49be85ee67b6;p=friendica.git diff --git a/src/Worker/RemoveUser.php b/src/Worker/RemoveUser.php index dfa5ccc097..72ead52642 100644 --- a/src/Worker/RemoveUser.php +++ b/src/Worker/RemoveUser.php @@ -1,17 +1,42 @@ . + * */ + namespace Friendica\Worker; +use Friendica\Core\Worker; use Friendica\Database\DBA; use Friendica\Model\Item; +use Friendica\Model\Post; -require_once 'include/dba.php'; - +/** + * Removes orphaned data from deleted users + */ class RemoveUser { - public static function execute($uid) + /** + * Removes user by id + * + * @param int $uid User id + * @return void + */ + public static function execute(int $uid) { // Only delete if the user is archived $condition = ['account_removed' => true, 'uid' => $uid]; @@ -20,6 +45,13 @@ class RemoveUser { } // Now we delete all user items - Item::delete(['uid' => $uid], PRIORITY_LOW); + $condition = ['uid' => $uid, 'deleted' => false]; + do { + $items = Post::select(['id'], $condition, ['limit' => 100]); + while ($item = Post::fetch($items)) { + Item::markForDeletionById($item['id'], Worker::PRIORITY_NEGLIGIBLE); + } + DBA::close($items); + } while (Post::exists($condition)); } }