-
-
Notifications
You must be signed in to change notification settings - Fork 147
Open
Labels
bugSomething isn't workingSomething isn't working
Milestone
Description
Bug Description
There's an inverted conditional in pop_transaction_id() at line 224 that prevents transactions from being properly removed from the queue, causing cart session mixing/corruption under concurrent requests.
Location
File: includes/utils/class-session-transaction-manager.php
Line: 224
The Bug
// Bail if not the expected mutation.
if ( str_starts_with( $this->transaction_id, "wooSession_{$mutation}_" ) ) {
return;
}The comment says "Bail if not the expected mutation" but the code bails when it IS the expected mutation. Missing ! operator.
Expected
if ( ! str_starts_with( $this->transaction_id, "wooSession_{$mutation}_" ) ) {
return;
}Impact
- Transactions are never popped from the queue
- Old cart snapshots accumulate in the transaction queue
- Under concurrent requests, cart state becomes corrupted (products disappear, wrong products appear)
Reproduction
- Start with empty cart
- Send 3 parallel
addToCartmutations with same session token - All 3 report success with
itemCount: 1 - Final cart check shows only 1 item (2 products silently lost)
Why It's Intermittent
The graphql_mutation_response hook fires for ALL mutations. When secondary mutations exist, the transaction may accidentally get popped (for the wrong reason). The bug manifests when only the primary cart mutation fires.
Environment
- wp-graphql-woocommerce: 0.19.0 (also verified in 0.21.2 and develop branch)
- WordPress: 6.x
- WooCommerce: 9.x
- PHP: 8.x
Suggested Fix
One-character change - add ! to line 224.
kidunot89
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working
Type
Projects
Status
Todo