From: Cyperghost Date: Fri, 8 Nov 2024 09:07:58 +0000 (+0100) Subject: Delete user avatar files when user accounts are deleted X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=4cae70a909661061e9f40399aa005a79d1276811;p=GitHub%2FWoltLab%2FWCF.git Delete user avatar files when user accounts are deleted --- diff --git a/wcfsetup/install/files/lib/data/user/UserAction.class.php b/wcfsetup/install/files/lib/data/user/UserAction.class.php index 7be5ec915b..96dd66b904 100644 --- a/wcfsetup/install/files/lib/data/user/UserAction.class.php +++ b/wcfsetup/install/files/lib/data/user/UserAction.class.php @@ -4,6 +4,7 @@ namespace wcf\data\user; use ParagonIE\ConstantTime\Hex; use wcf\data\AbstractDatabaseObjectAction; +use wcf\data\file\FileAction; use wcf\data\IClipboardAction; use wcf\data\ISearchAction; use wcf\data\object\type\ObjectTypeCache; @@ -139,16 +140,22 @@ class UserAction extends AbstractDatabaseObjectAction implements IClipboardActio } // delete avatars - $avatarIDs = []; + $avatarIDs = $avatarFileIDs = []; foreach ($this->getObjects() as $user) { if ($user->avatarID) { $avatarIDs[] = $user->avatarID; } + if ($user->avatarFileID !== null) { + $avatarFileIDs[] = $user->avatarFileID; + } } if (!empty($avatarIDs)) { $action = new UserAvatarAction($avatarIDs, 'delete'); $action->executeAction(); } + if (!empty($avatarFileIDs)) { + (new FileAction($avatarFileIDs, 'delete'))->executeAction(); + } // delete profile comments and signature attachments if (!empty($this->objectIDs)) {