get($this->userId); if (!$user) { // User has been deleted already return; } try { $setupManager = Server::get(SetupManager::class); $setupManager->tearDown(); $setupManager->setupForUser($user); $trashRoot = Server::get(IRootFolder::class)->getUserFolder($user->getUID())->getParent()->get('files_trashbin'); if (!$trashRoot instanceof Folder) { throw new \LogicException("Didn't expect files_trashbin to be a file instead of a folder"); } Trashbin::expire($trashRoot, $user); } catch (\Exception $e) { Server::get(LoggerInterface::class)->error('Error while expiring trashbin for user ' . $user->getUID(), ['exception' => $e]); } finally { $setupManager->tearDown(); } } }