File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -31,6 +31,8 @@ public function handle()
3131 $ this ->submission ->remove ($ field ->handle ());
3232 });
3333
34- $ this ->submission ->saveQuietly ();
34+ if ($ this ->submission ->form ()->store ()) {
35+ $ this ->submission ->saveQuietly ();
36+ }
3537 }
3638}
Original file line number Diff line number Diff line change 55use Illuminate \Support \Facades \Bus ;
66use PHPUnit \Framework \Attributes \DataProvider ;
77use PHPUnit \Framework \Attributes \Test ;
8+ use Statamic \Contracts \Forms \SubmissionRepository ;
89use Statamic \Facades \Form as FacadesForm ;
910use Statamic \Facades \Site ;
1011use Statamic \Forms \DeleteTemporaryAttachments ;
@@ -115,6 +116,29 @@ public function it_dispatches_delete_attachments_job_after_dispatching_email_job
115116 ]);
116117 }
117118
119+ #[Test]
120+ public function delete_attachments_job_only_saves_submission_when_enabled ()
121+ {
122+ $ form = tap (FacadesForm::make ('attachments_test ' )->email ([
123+ 'from ' => 'first@sender.com ' ,
124+ 'to ' => 'first@recipient.com ' ,
125+ 'foo ' => 'bar ' ,
126+ ]))->save ();
127+
128+ $ form
129+ ->store (false )
130+ ->blueprint ()
131+ ->ensureField ('attachments ' , ['type ' => 'files ' ])->save ();
132+
133+ $ submission = $ form ->makeSubmission ();
134+
135+ (new DeleteTemporaryAttachments ($ submission ))->handle ();
136+
137+ $ submissions = app (SubmissionRepository::class)->all ();
138+
139+ $ this ->assertEmpty ($ submissions );
140+ }
141+
118142 #[Test]
119143 #[DataProvider('noEmailsProvider ' )]
120144 public function no_email_jobs_are_queued_if_none_are_configured ($ emailConfig )
You can’t perform that action at this time.
0 commit comments