Docs › Releases › 1.07 › Changelog
Recurnix 1.07 changelog
Every change in 1.07, by kind. For what it means and whether to update, read the release notes.
Fixed
- A usage-capped coupon could be redeemed more times than its cap allows.
CouponService::validateForCart()counted the redemptions andCouponService::reserve()wrote a new one, with nothing holding those two moments together and the counting happening OUTSIDE the transaction that does the writing. Two customers checking out in the same second were both counted against the same remaining slot and both got the discount. Measured on the sandbox with two real PHP processes and a coupon capped at one redemption: while the first held a live reservation, the second reserved anyway, in 8 ms, with nothing stopping it. A coupon issued for the first 100 customers could be honoured 130 times, and nothing in the admin would have said so untiluseshad already run pastmax_uses. - The reservation now takes an exclusive lock on the coupon row and re-counts while holding it. The row is the rendezvous - every writer has to pass through it - so the second cart waits for the first to commit and then sees the reservation it wrote. Re-measured the same way: the second process waited out the full lock timeout and never got in.
- The cap rule was written out three times and the copies disagreed. Twice in
CouponService, and a third time inCoupon::isValidNow(), which comparedusesalone and so did not count a cart that was mid-checkout. That method had no callers anywhere in the application - it was simply sitting there being wrong. It is deleted, and the rule now lives in exactly one place,CouponService::capReached(), which both call. - A losing cart leaves nothing behind. The refusal is thrown as
App\Exceptions\CouponExhaustedfrom inside the single transaction that creates the order, its services and the invoice, so all of it unwinds together. The exception renders itself: the client is returned to their cart with the same message an ordinary "this coupon is used up" rejection shows. It is logged as one warning line rather than a stack trace - an operator wants to know a coupon is bouncing checkouts, but a sold-out coupon is not a crash. - A coupon deleted while someone had it in their cart raised a foreign-key violation, which reaches the customer as a 500. It is now refused by name, the same way an expired one is.
Changed
- Admin > Coupons: Total redemptions (
max_uses) had no lower bound, so0or a negative number could be saved - which made a coupon that could never be used, without saying so. The minimum is now 1, and the field states that carts still in checkout count against the total.
Added
tests/Unit/CouponCapTest.php- the cap rule across eight cases, plus an assertion thatreserve()still locks the coupon row, because a correct rule evaluated by two requests at the same instant is not a rule. Neither test needs a database or a booted application. The committed suite is now 11 passing tests (18 assertions), up from 2.