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
- Create a standard HTML form with
data-request="onSave"anddata-request-flash="true". - Add a standard submit button (
<button type="submit">Submit</button>). - Click the submit button once.
- Check the logs or database: the PHP handler
onSaveis 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…