civicrm/civicrm-core — pull request #3667 by rocxa (2014-07-15 10:19:05+00:00)
Title: Sold out line items fix

This is an initial attempt (needs work) to improve sold out price options fields handling so that no overbookings can occur and that the booker is informed appropriately.

Known issues:
1. it is not updated for some of the 4.5 changes. $this-> to CRM_Utils_Array::value()
2. The new logic should replace the form rules but at the moment acts independently
3. Updating the sold out options from peoples bookings is temperamental. (accessing the session directly is not the way to do this)
4. Some situations cause form rules to override the new logic and creates options which are frozen but also still checked resulting in the booker not being able to proceed.

Tested on:
2 bookers trying to book options with limit 1 on price option
2 bookers trying to each book 2 people with with limits 1 and 2 on different price options
3 bookers trying to each book 3 people with with limit 1, 2 and 3 on different price options.

We have also used this fix live and taken 350 bookings in one day over 134 different price options with no over bookings and only one person so far has bumped into the know issue 4 above.