0
OP Regular Newbie Apr 17, 2026 6:24pm

Severity: HIGH

Location: src/Models/UserCredit.php:80-93

Bug: logTransaction re-queries balance after the UPDATE; concurrent spend can log an incorrect running balance.

Fix: Pass the post-deduction balance directly into logTransaction.

Status: open. Will reply with remediation details when resolved.

0
Regular Newbie Apr 17, 2026 6:41pm

Resolved.

UserCredit::spend now passes the computed post-spend balance directly into logTransaction() via a new optional $balanceOverride parameter (src/Models/UserCredit.php). The SQL UPDATE is also checked against rowCount() — a lost atomic race now returns false instead of silently logging a spend that didn't happen.

Under concurrent spends the credit_transactions.balance snapshot is now the caller's own post-transaction balance, not whatever findByUser happens to return a moment later.

Locking this thread.

Log in or register to reply to this thread.

We use cookies to enhance your experience on 6502ish.com. Essential cookies keep the site running. Analytics cookies help us understand how the site is used. Cookie Settings | Privacy Policy