Double AJAX submission on forms using data-request (likely since v4.2.8)

Describe the bug Since updating OctoberCMS to version from 4.1.18 to 4.2.9, forms utilizing the standard data-request attribute are firing the AJAX handler twice on a single click, resulting in duplicate database entries.

I strongly suspect this is a regression related to the fix introduced in v4.2.8: “Fixes auto firing AJAX before session is ready”.

Steps to reproduce

  1. Create a standard HTML form with data-request="onSave" and data-request-flash="true".
  2. Add a standard submit button (<button type="submit">Submit</button>).
  3. Click the submit button once.
  4. Check the logs or database: the PHP handler onSave is executed twice almost simultaneously.

Expected behavior The AJAX framework should prevent the default form submission and fire the AJAX request only once per user interaction.

Workaround currently used To prevent duplicate data, I currently have to implement backend atomic locking (Cache::add()) and/or change the button to type="button" with custom JS to block concurrent requests.

Environment:

  • OctoberCMS Version: 4.2.9
  • PHP Version: PHP 8.2

{framework} and {framework extras} are alone in the layout, and nowhere else…

Ok !
I found that having {% framework %} and {% framework extras %} in my layout is not need anymore (I use October CMS since its v1.) and causing this issue.

Many thanks to Chris, helping me to debug with its Inspector network graph !

1 Like