Skip to content

Commit

Permalink
Delete user avatar files when user accounts are deleted
Browse files Browse the repository at this point in the history
  • Loading branch information
Cyperghost committed Nov 8, 2024
1 parent 315043d commit 4cae70a
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion wcfsetup/install/files/lib/data/user/UserAction.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

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;
Expand Down Expand Up @@ -139,16 +140,22 @@ public function delete()
}

// 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)) {
Expand Down

0 comments on commit 4cae70a

Please sign in to comment.