Skip the default cover photo when rebuilding users
authorAlexander Ebert <ebert@woltlab.com>
Mon, 20 Sep 2021 12:17:50 +0000 (14:17 +0200)
committerAlexander Ebert <ebert@woltlab.com>
Mon, 20 Sep 2021 12:17:50 +0000 (14:17 +0200)
Fixes #4500

wcfsetup/install/files/lib/system/worker/UserRebuildDataWorker.class.php

index f991414682dab53ca9ede4f352822ac6d5cc1d38..eeb12f0d76997e9cdcf050d189cda33c21db783e 100644 (file)
@@ -6,6 +6,7 @@ use wcf\data\reaction\type\ReactionTypeCache;
 use wcf\data\user\avatar\UserAvatar;
 use wcf\data\user\avatar\UserAvatarEditor;
 use wcf\data\user\avatar\UserAvatarList;
+use wcf\data\user\cover\photo\DefaultUserCoverPhoto;
 use wcf\data\user\cover\photo\IWebpUserCoverPhoto;
 use wcf\data\user\User;
 use wcf\data\user\UserEditor;
@@ -300,6 +301,11 @@ class UserRebuildDataWorker extends AbstractRebuildDataWorker
             foreach ($userProfiles as $userProfile) {
                 $editor = new UserEditor($userProfile->getDecoratedObject());
                 $coverPhoto = $userProfile->getCoverPhoto(true);
+                if ($coverPhoto instanceof DefaultUserCoverPhoto) {
+                    // The default cover photo can be returned if the user has a
+                    // cover photo, but it has been disabled by an administrator.
+                    continue;
+                }
 
                 // If neither the regular, nor the WebP variant is readable then the
                 // cover photo is missing and we must clear the database information.