From d0e734a8d432646bc5477987e8e219363e341c6d Mon Sep 17 00:00:00 2001 From: Ollie Date: Tue, 1 Sep 2026 10:36:16 +0100 Subject: [PATCH] Add warning docblock to SendPolicyAnnouncementJob Add a warning to try and prevent us from copying this pattern in the future. Bug: T432211 --- app/Jobs/SendPolicyAnnouncementJob.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/app/Jobs/SendPolicyAnnouncementJob.php b/app/Jobs/SendPolicyAnnouncementJob.php index b4b48b98..75a835ab 100644 --- a/app/Jobs/SendPolicyAnnouncementJob.php +++ b/app/Jobs/SendPolicyAnnouncementJob.php @@ -6,6 +6,16 @@ use App\User; use Illuminate\Support\Facades\Notification; +/** + * WARNING: This job is NOT idempotent. DO NOT RUN IT MULTIPLE TIMES. + * There is also no error handling or mechanism for recording which users have been sent an email. + * + * This has created an issue on production where a user with an empty string as an email address + * (due to a request to remove PII) caused Notification::send() to throw an error and the remaining + * emails to not be sent. + * + * DO NOT REPEAT THIS PATTERN FOR OTHER JOBS + */ class SendPolicyAnnouncementJob extends Job { public function handle() { $users = User::query()->whereNotNull('email')->get();