From 9c76c5989de2a717330f0a7002d3846f68ceb473 Mon Sep 17 00:00:00 2001 From: xiaomlove Date: Wed, 18 Jun 2025 12:09:08 +0700 Subject: [PATCH] update user clear cache outside transaction --- app/Repositories/UserRepository.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/app/Repositories/UserRepository.php b/app/Repositories/UserRepository.php index 78429a71..1b7d3819 100644 --- a/app/Repositories/UserRepository.php +++ b/app/Repositories/UserRepository.php @@ -405,11 +405,12 @@ class UserRepository extends BaseRepository $message['subject'] = nexus_trans('message.download_enable.subject', [], $targetUser->locale); $message['msg'] = nexus_trans('message.download_enable.body', ['operator' => $operatorUsername], $targetUser->locale); } - return NexusDB::transaction(function () use ($targetUser, $update, $modComment, $message) { + $result = NexusDB::transaction(function () use ($targetUser, $update, $modComment, $message) { Message::add($message); - $this->clearCache($targetUser); return $targetUser->updateWithModComment($update, $modComment); }); + $this->clearCache($targetUser); + return $result; } @@ -506,8 +507,8 @@ class UserRepository extends BaseRepository $targetUser->usernameChangeLogs()->create($changeLog); $targetUser->username = $changeLog['username_new']; $targetUser->save(); - $this->clearCache($targetUser); }); + $this->clearCache($targetUser); return true; } @@ -566,8 +567,8 @@ class UserRepository extends BaseRepository } else { $targetUser->update($userUpdates); } - $this->clearCache($targetUser); }); + $this->clearCache($targetUser); return true; }