Skip Menu |

This queue is for tickets about the Maypole CPAN distribution.

Report information
The Basics
Id: 6500
Status: resolved
Priority: 0/
Queue: Maypole

People
Owner: TEEJAY [...] cpan.org
Requestors: jester [...] panix.com
Cc:
AdminCc:

Bug Information
Severity: Wishlist
Broken in: (no value)
Fixed in:
  • 2.11
  • 2.11_pre1
  • 2.11_pre2
  • 2.11_pre3
  • 2.11_pre5

Attachments
mult-submit-patches.tar



Subject: Multiple form submission issues
A collection of patches to address the problem of multiple form submissions (as discussed on the list), as when a user clicks the "reload" button on the browser and ignores the POST data warning, or uses the "back" button and submits again. These patches have no effect if their use is not desired, but if they are, they will ensure that a form cannot accidentally be submitted twice. Maypole-patch patches Maypole.pm to provide the make_random_id method. This simply uses and then calls Apache::Session::Generate::MD5::generate(), which returns a 32-character random string, and doesn't do any session stuff at all. (Indeed, putting this in Maypole itself could make it useful for other things.) If you don't want to use the A::S::G::MD5::generate, you can manually put in the identical lines, or it can be overridden easily. CDBI-patch patches CDBI.pm to provide the guts of the functionality: if sessions are running, _and_ if the user is passing around form_id parameters, the form_id value will be put in the session, and any further form submission using the same form_id will place an error message (itself configurable in DriverDB->config->{table_name}{mult_submit_err_msg} ) into $r->{template_args}{messages}, and bounce the user back to the list template. If the application is not using sessions, or if it is using sessions but is not using form_id values, then nothing will happen. Finally addnew-patch and edit-patch are patches for those templates in the templates/factory/ directory, in each case adding a hidden form field named form_id containing a random id value as generated by make_random_id. Again, it's OK to put this in the factory templates, since if the user is not using sessions, nothing happens. (It's also trivially fast to generate the random numbers; I did a benchmark on a slow computer and was able to generate 15,000 such form_id values in one second.)
Download mult-submit-patches.tar
application/x-tar 20k

Message body not shown because it is not plain text.

[JESTER - Thu Jun 3 09:41:41 2004]: Show quoted text
> A collection of patches to address the problem of multiple form > submissions (as discussed on the list), as when a user clicks the > "reload" button on the browser and ignores the POST data warning, > or uses the "back" button and submits again. These patches have no > effect if their use is not desired, but if they are, they will > ensure that a form cannot accidentally be submitted twice. >
I have applied most of the patches with a small mod to Mapole SVN. Unfortunately the CDBI patch provided was just the other patches tarred up so I didn't get to see that. I have left it so that ids are generated and pulled into the templates, the user can then store/check them as they wish. TEEJAY
I believe this is resolved in 2.11 where the unique form id is generated and provided in each form, allowing you to check for multiple submissions.