From 1fe8a30feea9cb2fef5f075ed44d24b546d38b60 Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Wed, 14 Dec 2016 17:40:17 +0100 Subject: [PATCH] Remove missing or broken avatars --- .../lib/system/worker/UserRebuildDataWorker.class.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/wcfsetup/install/files/lib/system/worker/UserRebuildDataWorker.class.php b/wcfsetup/install/files/lib/system/worker/UserRebuildDataWorker.class.php index f15cad81cd..4031dbc9d9 100644 --- a/wcfsetup/install/files/lib/system/worker/UserRebuildDataWorker.class.php +++ b/wcfsetup/install/files/lib/system/worker/UserRebuildDataWorker.class.php @@ -103,6 +103,13 @@ class UserRebuildDataWorker extends AbstractRebuildDataWorker { $avatarList->getConditionBuilder()->add('(user_avatar.width <> ? OR user_avatar.height <> ?)', [UserAvatar::AVATAR_SIZE, UserAvatar::AVATAR_SIZE]); $avatarList->readObjects(); foreach ($avatarList as $avatar) { + $editor = new UserAvatarEditor($avatar); + if (!file_exists($avatar->getLocation()) || @getimagesize($avatar->getLocation()) === false) { + // delete avatars that are missing or broken + $editor->delete(); + continue; + } + $width = $avatar->width; $height = $avatar->height; if ($width != $height) { @@ -123,7 +130,6 @@ class UserRebuildDataWorker extends AbstractRebuildDataWorker { $width = $height = UserAvatar::AVATAR_SIZE; } - $editor = new UserAvatarEditor($avatar); $editor->update([ 'width' => $width, 'height' => $height -- 2.20.1