From 793d2c3ef3d9d9c1f0048120ae98ba9893b02333 Mon Sep 17 00:00:00 2001 From: Shannon Quinn Date: Fri, 17 Jul 2026 09:53:20 -0400 Subject: [PATCH] Invalidate landing contact cache on user-side admin profile edits When an admin updates their avatar, bio, or display name via the regular Settings UI (not the admin panel), AvatarOptimize and HomeSettings::homeUpdate previously only invalidated the per-profile caches. The api:v1:instance-data:contact key, which embeds the admin's account object on the landing page and at /api/v(1|2)/instance, remained cached for up to 7 days (also the source of many hours' headaches). AvatarOptimize now also calls AccountService::del() (the underlying pf:services:account: cache, which had been left stale) and, if the profile backs the configured contact account, LandingCacheService::invalidateContact(). HomeSettings does the contact hit too. The profileBacksContact helper mirrors the resolution order in LandingService::get(): prefer instance.admin.pid when set, else fall back to the first is_admin user. --- app/Http/Controllers/Settings/HomeSettings.php | 4 ++++ app/Jobs/AvatarPipeline/AvatarOptimize.php | 10 ++++++++++ 2 files changed, 14 insertions(+) diff --git a/app/Http/Controllers/Settings/HomeSettings.php b/app/Http/Controllers/Settings/HomeSettings.php index 8d73a3ed7..ceea39e0f 100644 --- a/app/Http/Controllers/Settings/HomeSettings.php +++ b/app/Http/Controllers/Settings/HomeSettings.php @@ -7,6 +7,7 @@ use App\EmailVerification; use App\Mail\PasswordChange; use App\Media; use App\Services\AccountService; +use App\Services\LandingCacheService; use App\Services\PronounService; use App\Util\Lexer\Autolink; use App\Util\Lexer\PrettyNumber; @@ -102,6 +103,9 @@ trait HomeSettings Cache::forget('user:account:id:'.$user->id); AccountService::forgetAccountSettings($profile->id); AccountService::del($profile->id); + if (LandingCacheService::profileBacksContact((int) $profile->id)) { + LandingCacheService::invalidateContact(); + } return redirect('/settings/home')->with('status', 'Profile successfully updated!'); } diff --git a/app/Jobs/AvatarPipeline/AvatarOptimize.php b/app/Jobs/AvatarPipeline/AvatarOptimize.php index ea0786b30..f4178a799 100644 --- a/app/Jobs/AvatarPipeline/AvatarOptimize.php +++ b/app/Jobs/AvatarPipeline/AvatarOptimize.php @@ -4,6 +4,8 @@ namespace App\Jobs\AvatarPipeline; use App\Avatar; use App\Profile; +use App\Services\AccountService; +use App\Services\LandingCacheService; use App\Util\Media\ImageDriverManager; use Cache; use Carbon\Carbon; @@ -96,6 +98,10 @@ class AvatarOptimize implements ShouldQueue $avatar->last_processed_at = Carbon::now(); $avatar->save(); Cache::forget('avatar:'.$avatar->profile_id); + AccountService::del($avatar->profile_id); + if (LandingCacheService::profileBacksContact((int) $avatar->profile_id)) { + LandingCacheService::invalidateContact(); + } $this->deleteOldAvatar($avatar->media_path, $this->current); if ((bool) config_cache('pixelfed.cloud_storage') && (bool) config_cache('instance.avatar.local_to_cloud')) { @@ -132,5 +138,9 @@ class AvatarOptimize implements ShouldQueue $avatar->save(); Storage::delete($avatar->media_path); Cache::forget('avatar:'.$avatar->profile_id); + AccountService::del($avatar->profile_id); + if (LandingCacheService::profileBacksContact((int) $avatar->profile_id)) { + LandingCacheService::invalidateContact(); + } } }