From: Alexander Ebert Date: Thu, 5 Aug 2021 11:39:03 +0000 (+0200) Subject: Reset the avatar cache to force the use of the WebP variants X-Git-Tag: 5.4.3~21 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=86a8244b3d136e10e2c14e26e47688cccf4496a7;p=GitHub%2FWoltLab%2FWCF.git Reset the avatar cache to force the use of the WebP variants Fixes #4424 --- diff --git a/com.woltlab.wcf/package.xml b/com.woltlab.wcf/package.xml index 888fa1b456..b4d7a5e27f 100644 --- a/com.woltlab.wcf/package.xml +++ b/com.woltlab.wcf/package.xml @@ -156,5 +156,6 @@ tar cvf com.woltlab.wcf/files_pre.tar -C wcfsetup/install/files/ \ acp/update_com.woltlab.wcf_5.4.3_deleteDsStore.php + acp/update_com.woltlab.wcf_5.4.3_resetAvatarCache.php diff --git a/wcfsetup/install/files/acp/update_com.woltlab.wcf_5.4.3_resetAvatarCache.php b/wcfsetup/install/files/acp/update_com.woltlab.wcf_5.4.3_resetAvatarCache.php new file mode 100644 index 0000000000..28d1b43ddb --- /dev/null +++ b/wcfsetup/install/files/acp/update_com.woltlab.wcf_5.4.3_resetAvatarCache.php @@ -0,0 +1,16 @@ + + * @package WoltLabSuite\Core + */ + +use wcf\system\user\storage\UserStorageHandler; + +UserStorageHandler::getInstance()->resetAll('avatar'); diff --git a/wcfsetup/install/files/lib/system/worker/UserRebuildDataWorker.class.php b/wcfsetup/install/files/lib/system/worker/UserRebuildDataWorker.class.php index 0df26ad722..77f32e3fc7 100644 --- a/wcfsetup/install/files/lib/system/worker/UserRebuildDataWorker.class.php +++ b/wcfsetup/install/files/lib/system/worker/UserRebuildDataWorker.class.php @@ -17,6 +17,7 @@ use wcf\system\database\util\PreparedStatementConditionBuilder; use wcf\system\exception\SystemException; use wcf\system\html\input\HtmlInputProcessor; use wcf\system\image\ImageHandler; +use wcf\system\user\storage\UserStorageHandler; use wcf\system\WCF; /** @@ -227,7 +228,10 @@ class UserRebuildDataWorker extends AbstractRebuildDataWorker ] ); $avatarList->readObjects(); + $resetAvatarCache = []; foreach ($avatarList as $avatar) { + $resetAvatarCache[] = $avatar->userID; + $editor = new UserAvatarEditor($avatar); if (!\file_exists($avatar->getLocation()) || @\getimagesize($avatar->getLocation()) === false) { // delete avatars that are missing or broken @@ -282,6 +286,11 @@ class UserRebuildDataWorker extends AbstractRebuildDataWorker ]); } + // Reset the avatar cache for all avatars that had been processed. + if (!empty($resetAvatarCache)) { + UserStorageHandler::getInstance()->reset($resetAvatarCache, 'avatar'); + } + // Create WebP variants of existing cover photos. $userProfiles = new UserProfileList(); $userProfiles->getConditionBuilder()->add("user_table.userID IN (?)", [$userIDs]);