Skip to content

v2.12.3

Latest

Choose a tag to compare

@mckenziearts mckenziearts released this 19 Nov 22:55
745ec77

What's New

Security

  • fix(stock): read the committed stock when reserving inside a transaction (#703)

Two concurrent checkouts could both reserve the last unit of a product on MySQL. CreateOrderFromCartAction opens a transaction and reads the cart before it reserves stock. Under repeatable read, that first read fixes the snapshot: the second checkout waited for the product lock, then read the stock from the snapshot taken before the wait, and reserved stock that was gone.

Inside a transaction, HasStock::stockInventory() now locks the history rows of the product for that inventory and reads the committed quantities. Outside a transaction the query is unchanged. PostgreSQL was not affected. This is the 2.x port of the fix shipped in v3.0.0-rc.9 (#702).

Upgrading

composer update "shopper/*"

No migration and no configuration change. If you replaced Shopper\Core\Contracts\StockAllocator with your own class, read the available stock through stockInventory(): getStock() is not locked.

Contributors

@mckenziearts

Thanks to adamyordan for reporting the stock reservation race.

Full Changelog: v2.12.2...v2.12.3