From 5eeb2b67c2ce82a87bc5e2d2d1592b8c69753768 Mon Sep 17 00:00:00 2001 From: Simon Date: Thu, 28 Nov 2024 12:33:51 +0100 Subject: [PATCH 1/4] fix: missing release of registered evenrts --- src/Jobs/CheckAndUpdateUserEmail.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Jobs/CheckAndUpdateUserEmail.php b/src/Jobs/CheckAndUpdateUserEmail.php index 37905ad..248cc1d 100644 --- a/src/Jobs/CheckAndUpdateUserEmail.php +++ b/src/Jobs/CheckAndUpdateUserEmail.php @@ -76,6 +76,8 @@ public function handle(UserValidator $validator) $user->changeEmail($this->providedEmail); $user->save(); + + $user->releaseEvents(); } } } From e7026926b55c3c8768948c3c5890c612e3e1a0fb Mon Sep 17 00:00:00 2001 From: Simon Date: Thu, 28 Nov 2024 12:34:53 +0100 Subject: [PATCH 2/4] chore: format --- src/Jobs/CheckAndUpdateUserEmail.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/Jobs/CheckAndUpdateUserEmail.php b/src/Jobs/CheckAndUpdateUserEmail.php index 248cc1d..81b0756 100644 --- a/src/Jobs/CheckAndUpdateUserEmail.php +++ b/src/Jobs/CheckAndUpdateUserEmail.php @@ -76,8 +76,7 @@ public function handle(UserValidator $validator) $user->changeEmail($this->providedEmail); $user->save(); - - $user->releaseEvents(); + $user->releaseEvents(); } } } From ba7e2fdc2e604e2a46dc8d58dba176bd1f5a6522 Mon Sep 17 00:00:00 2001 From: Simon Date: Thu, 28 Nov 2024 12:54:22 +0100 Subject: [PATCH 3/4] fix: dispatch the released events --- src/Jobs/CheckAndUpdateUserEmail.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/Jobs/CheckAndUpdateUserEmail.php b/src/Jobs/CheckAndUpdateUserEmail.php index 81b0756..64a2ced 100644 --- a/src/Jobs/CheckAndUpdateUserEmail.php +++ b/src/Jobs/CheckAndUpdateUserEmail.php @@ -15,6 +15,7 @@ use Flarum\User\User; use Flarum\User\UserValidator; use Illuminate\Bus\Queueable; +use Illuminate\Contracts\Events\Dispatcher; use Illuminate\Contracts\Queue\ShouldQueue; use Illuminate\Queue\SerializesModels; @@ -51,7 +52,7 @@ public function __construct(string $providerName, $identifier, ?string $provided $this->providedEmail = $providedEmail; } - public function handle(UserValidator $validator) + public function handle(UserValidator $validator, Dispatcher $events) { $provider = LoginProvider::where('provider', $this->providerName)->where('identifier', $this->identifier)->first(); @@ -76,7 +77,10 @@ public function handle(UserValidator $validator) $user->changeEmail($this->providedEmail); $user->save(); - $user->releaseEvents(); + + foreach ($user->releaseEvents() as $event) { + $events->dispatch($event); + } } } } From 8b86b1e2d58052b700972327a7f150eec4e98899 Mon Sep 17 00:00:00 2001 From: Simon Date: Thu, 28 Nov 2024 12:55:24 +0100 Subject: [PATCH 4/4] chore: format --- src/Jobs/CheckAndUpdateUserEmail.php | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/Jobs/CheckAndUpdateUserEmail.php b/src/Jobs/CheckAndUpdateUserEmail.php index 64a2ced..cdfbb99 100644 --- a/src/Jobs/CheckAndUpdateUserEmail.php +++ b/src/Jobs/CheckAndUpdateUserEmail.php @@ -77,10 +77,9 @@ public function handle(UserValidator $validator, Dispatcher $events) $user->changeEmail($this->providedEmail); $user->save(); - - foreach ($user->releaseEvents() as $event) { - $events->dispatch($event); - } + foreach ($user->releaseEvents() as $event) { + $events->dispatch($event); + } } } }