mplodowski / formbuilder-plugin-public

https://octobercms.com/plugin/renatio-formbuilder
https://octobercms.com/plugin/renatio-formbuilder
1 stars 0 forks source link

File upload file being attached to wrong form log #52

Open adrian-stein opened 1 month ago

adrian-stein commented 1 month ago

Describe the bug Form attachments are getting saved to the wrong form log. We have large volumes of traffic and people are filling in forms at the same time and it causes the attachment to be attached to the wrong log.

To Reproduce Steps to reproduce the behaviour:

  1. Start to complete a form and upload a file for submission.
  2. Then in a separate browser or even computer also start to submit a form. (It does not have to be the same form)
  3. Submit the second form before submitting the form with the file ready to be uploaded the file is attached to the second form log.
  4. submit the first form and no file is attached even though it is in the form data

October version 2.2.35

Plugin version 2.2.0

Additional context I can see the file get added to system_files with these fields not filled in (field, attachment_id, attachment_type). Then when the second form is submitted the field name and form log ID are added but it is the log from the second form with no upload fields. Should the file not get added to the system_files table with some kind of session_id so it can only then be linked with the form log with the same session_id?

mplodowski commented 1 month ago

Hi,

sorry to hear that. Your plugin version is very old from May 2022. In the latest version this bug is fixed.

The solution was to move to native ajax upload functionality built in October 3.

I know it is some work to upgrade October to version 3 and then upgrade FormBuilder plugin, but you should consider this.

adrian-stein commented 1 month ago

Hey there,

I am not in a position to upgrade to oct 3 quite yet. Are you able to point me in the direction as to where the code is that handles attaching the file to the logs and or any tips on how to fix it. I will probably need to patch this myself for the time being before I am able to upgrade.

Thanks, Adrian

mplodowski commented 1 month ago

You can check listeners/SendEmailMessage.php there is attachFiles() function, which attach files to email. Check if those files are correctly attached.

I use Upload plugin so the logic to save uploaded files is there.

In setHeaders() function the log entry is created.

I hope you figure this out.