From 26f3b12b65bc28b2352fa4b5b74fd5cf895a5918 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Tim=20D=C3=BCsterhus?= Date: Fri, 20 Aug 2021 09:35:35 +0200 Subject: [PATCH] Remove records of unreadable cover photos in UserRebuildDataWorker This is a clean fix of c3ebf8b995927b826072cfcc72d08a9ebd93f878. --- .../system/worker/UserRebuildDataWorker.class.php | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/wcfsetup/install/files/lib/system/worker/UserRebuildDataWorker.class.php b/wcfsetup/install/files/lib/system/worker/UserRebuildDataWorker.class.php index b8b4e29937..f991414682 100644 --- a/wcfsetup/install/files/lib/system/worker/UserRebuildDataWorker.class.php +++ b/wcfsetup/install/files/lib/system/worker/UserRebuildDataWorker.class.php @@ -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([ -- 2.20.1