Repository navigation
[6.x] Forms 2: Fix submission events, uploads and cleanup - #15963
Merged
Merged
Conversation
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Jobs that aren't queueable or have no public $middleware (e.g. a custom send_email_job) are dispatched first and treated as done once dispatched, so temporary file cleanup isn't left pending. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…onCreated on finalize only FormSubmitted, SubmissionCreated, SubmissionSaved and SubmissionFinalized listeners now see real asset paths with the assets already created, like on 6.x. If a FormSubmitted listener rejects the submission or marks it as spam, the assets are removed again and the temporary uploads are kept. Partial saves no longer fire SubmissionCreated. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Files posted under any other handle, or nested inside a field like a group, are dropped instead of being uploaded or replacing the field's value. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Files posted for upload fields on another page of a multi-page form skipped validation but were still uploaded, e.g. into a public asset container through a fieldset-imported assets field. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
_partial, _site, _marked_spam_at and other underscore-prefixed keys are held separately, so data() returns only field values (as on 6.x) and stays the live collection. get(), set(), has() and remove() still reach them, and fileData() includes them, so the stored format is unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Avoids using the void result of save(), which PHPStan flags, while still not firing the event when a SubmissionSaving listener vetoes the save. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Matches 6.x, where get() fell back when a stored value was null. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Also covers re-saving or re-finalizing a finalized submission not firing SubmissionCreated again, and updates comments that still described the old created-on-partial behaviour. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Partial saves of multi-page forms now only fire SubmissionSaving/SubmissionSaved. Finalizing fires SubmissionCreating with the complete data, then saves and fires SubmissionCreated. Single-page and non-storing forms fire the same events as on 6.x. Vetoing SubmissionCreating at finalize deletes the stored partial instead of finalizing it, and the rest of finalizing (emails, connections, cleanup) still runs, since a veto only prevents storage. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
If a SubmissionCreating listener vetoes finalizing a stored spam submission, it now stays exactly as it was: the created assets are removed, the temporary uploads are kept, and nothing else runs (no delete, no SubmissionCreated/SubmissionFinalized, no emails or connections). The Mark as Not Spam action reports these as failures. A vetoed finalize of a normal multi-page submission is unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes to the form submission pipeline.
FormSubmitted,SubmissionCreated,SubmissionSavedandSubmissionFinalizedlisteners see real asset paths, with the assets already created (as on 6.x). If aFormSubmittedlistener rejects the submission or marks it as spam, the assets are removed again and the temporary uploads are kept, so "mark as not spam" still works.SubmissionSaving/SubmissionSaved.SubmissionCreating(with the complete data) andSubmissionCreatedfire when the submission is finalized. Single-page forms and forms that don't store submissions fire the same events as on 6.x.SubmissionCreatinglistener returnsfalsewhen a multi-page submission is finalized, the stored partial is deleted instead of finalized. As with single-page forms, this only prevents storage: emails, connections and cleanup still run.SubmissionCreatinglistener returnsfalsewhen "Mark as not spam" finalizes a stored spam submission, the submission is left exactly as it was: still spam, its temporary uploads kept, and no assets, emails or connections. The action reports it as a failure.$submission->data()returns field values only, as on 6.x._partial,_siteand_marked_spam_atare still stored and reachable throughget()/set()/has()/remove(), andfileData()includes them, so the stored format is unchanged. Repositories that save submissions should usefileData()(the eloquent driver will).send_email_job(or any connection job) that isn't queueable or has no public$middlewareno longer causes a 500 after the submission is saved. It's dispatched first and treated as done once dispatched, so temporary file cleanup still happens.upload, plusassets/filesfields imported from fieldsets) on the current page accept files. Files posted for fields on another page (which skipped validation and could be written into a public asset container), under non-upload handles, or nested inside a group are dropped. They no longer replace the group's value.Tests
DeleteTemporaryFilesTest::it_does_not_bring_back_a_submission_deleted_before_the_job_runsConnectionCleanupTest: jobs withoutShouldQueueor a public$middlewarerun and cleanup still happens; a non-queueable customsend_email_jobstill sends; those jobs run before the countable ones and don't hold up cleanup.SubmitFormTest:listeners_see_the_real_asset_path_and_the_asset_already_exists,assets_created_for_a_listener_are_removed_when_the_listener_rejects_the_submission,a_submission_marked_as_spam_by_a_listener_keeps_its_temporary_upload_instead_of_the_asset,submission_created_only_fires_when_a_multi_page_submission_is_finalized, exact event sequences for single-page (storing / not storing), multi-page partial saves and finalize (storing / not storing), and aSubmissionCreatingveto at finalize (single- and multi-page), plus a vetoed "Mark as not spam" (record and uploads unchanged, onlySubmissionCreatingfires) and the action's failure messages inMarkAsNotSpamTest,a_file_posted_inside_a_group_is_ignored_and_the_groups_other_values_are_kept,a_file_posted_under_a_field_that_isnt_an_upload_field_is_ignored,files_posted_for_an_upload_field_on_another_page_are_ignoredSubmissionTest: internal keys are stored but kept out ofdata(), which stays the live collection.SubmissionCreating/SubmissionCreatedon partial saves and internal keys indata()were updated.