Hello,
I have a booking form (using SmartForms) that, on submission, checks if an event (LISE item) has any spaces available. It does this by reading the value of the "spaces" field (UDT).
If spaces are available, the form updates the event's spaces, saves the booking (in another LISE instance), and completes the rest of the dispositions.
The issue I'm running into is race conditions - multiple submissions can overlap and allow overbooking.
Is there a way in my UDT to access a LISE item's "spaces" field and lock it while performing the check?
Thanks
James
Preventing Race Conditions in SmartForms with LISE
Re: Preventing Race Conditions in SmartForms with LISE
Hi James
at this point there is no locking mechanism in LISE and the one in the works is for the editor, at least for now. But you raise a good point, and I'll look into this for a future release.
A possible solution would require some very smart PHP coding in the UDT, either by using a tmp file with a name that could be meaningful and unique that would be locked immediately on submission and only unlocked at the end of the process whether the booking succeeded or not. I don't know how your system works in detail, but that may work, although I can see some issues with the solution. There can be a few different flavors of this but this would be the gist. Using a db lock would also work but you'd need a bit more complex programing.
at this point there is no locking mechanism in LISE and the one in the works is for the editor, at least for now. But you raise a good point, and I'll look into this for a future release.
A possible solution would require some very smart PHP coding in the UDT, either by using a tmp file with a name that could be meaningful and unique that would be locked immediately on submission and only unlocked at the end of the process whether the booking succeeded or not. I don't know how your system works in detail, but that may work, although I can see some issues with the solution. There can be a few different flavors of this but this would be the gist. Using a db lock would also work but you'd need a bit more complex programing.
"There are 10 types of people in this world, those who understand binary... and those who don't."
* by the way: English is NOT my native language (sorry for any mistakes...).
Code of Condut | CMSMS Docs | Help Support CMSMS
My developer Page on the Forge
GeekMoot 2015 in Ghent, Belgium: I was there!
GeekMoot 2016 in Leicester, UK: I was there!
DevMoot 2023 in Cynwyd, Wales: I was there!
* by the way: English is NOT my native language (sorry for any mistakes...).
Code of Condut | CMSMS Docs | Help Support CMSMS
My developer Page on the Forge
GeekMoot 2015 in Ghent, Belgium: I was there!
GeekMoot 2016 in Leicester, UK: I was there!
DevMoot 2023 in Cynwyd, Wales: I was there!