From f68296a6db00458b55e41d73ba91b2a381479785 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Tim=20D=C3=BCsterhus?= Date: Tue, 23 Feb 2021 16:53:26 +0100 Subject: [PATCH] Delete legacy avatar thumbnails in UserRebuildDataWorker Resolves #4010 --- .../user/avatar/UserAvatarEditor.class.php | 19 +++++++++++++------ .../worker/UserRebuildDataWorker.class.php | 1 + 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/wcfsetup/install/files/lib/data/user/avatar/UserAvatarEditor.class.php b/wcfsetup/install/files/lib/data/user/avatar/UserAvatarEditor.class.php index ea7e859588..f8352f08a7 100644 --- a/wcfsetup/install/files/lib/data/user/avatar/UserAvatarEditor.class.php +++ b/wcfsetup/install/files/lib/data/user/avatar/UserAvatarEditor.class.php @@ -58,19 +58,26 @@ class UserAvatarEditor extends DatabaseObjectEditor } /** - * Deletes avatar files. + * Deletes the legacy thumbnail sizes. + * + * @since 5.4 + * @deprecated 5.4 This relies on the deprecated UserAvatar::$avatarThumbnailSizes. */ - public function deleteFiles() + public function deleteLegacyThumbnails(): void { // delete wcf2.1 files foreach (UserAvatar::$avatarThumbnailSizes as $size) { - if ($this->width < $size && $this->height < $size) { - break; - } - @\unlink($this->getLocation($size, false)); } @\unlink($this->getLocation('resize', false)); + } + + /** + * Deletes avatar files. + */ + public function deleteFiles() + { + $this->deleteLegacyThumbnails(); // delete original size @\unlink($this->getLocation(null, false)); diff --git a/wcfsetup/install/files/lib/system/worker/UserRebuildDataWorker.class.php b/wcfsetup/install/files/lib/system/worker/UserRebuildDataWorker.class.php index ea1b517482..6423618e51 100644 --- a/wcfsetup/install/files/lib/system/worker/UserRebuildDataWorker.class.php +++ b/wcfsetup/install/files/lib/system/worker/UserRebuildDataWorker.class.php @@ -271,6 +271,7 @@ class UserRebuildDataWorker extends AbstractRebuildDataWorker $width = $height = UserAvatar::AVATAR_SIZE; } + $editor->deleteLegacyThumbnails(); $editor->createAvatarVariant(); $editor->update([ -- 2.20.1