Remove records of unreadable cover photos in UserRebuildDataWorker
authorTim Düsterhus <duesterhus@woltlab.com>
Fri, 20 Aug 2021 07:35:35 +0000 (09:35 +0200)
committerTim Düsterhus <duesterhus@woltlab.com>
Fri, 20 Aug 2021 07:35:35 +0000 (09:35 +0200)
This is a clean fix of c3ebf8b995927b826072cfcc72d08a9ebd93f878.

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

index b8b4e2993723aebea05f22fceb3e7efc2cf4bca0..f991414682dab53ca9ede4f352822ac6d5cc1d38 100644 (file)
@@ -300,6 +300,21 @@ class UserRebuildDataWorker extends AbstractRebuildDataWorker
             foreach ($userProfiles as $userProfile) {
                 $editor = new UserEditor($userProfile->getDecoratedObject());
                 $coverPhoto = $userProfile->getCoverPhoto(true);
+
+                // If neither the regular, nor the WebP variant is readable then the
+                // cover photo is missing and we must clear the database information.
+                if (
+                    !\is_readable($coverPhoto->getLocation(false))
+                    && !\is_readable($coverPhoto->getLocation(true))
+                ) {
+                    $editor->update([
+                        'coverPhotoHash' => null,
+                        'coverPhotoExtension' => '',
+                    ]);
+
+                    continue;
+                }
+
                 if ($coverPhoto instanceof IWebpUserCoverPhoto) {
                     $coverPhoto->createWebpVariant();
                     $editor->update([