diff --git a/src/inventory/transaction/InventoryTransaction.php b/src/inventory/transaction/InventoryTransaction.php index 6e010c7b8..99fa6a097 100644 --- a/src/inventory/transaction/InventoryTransaction.php +++ b/src/inventory/transaction/InventoryTransaction.php @@ -95,10 +95,13 @@ class InventoryTransaction{ } /** - * Returns an **unordered** set of actions involved in this transaction. + * Returns a set of actions involved in this transaction. * - * WARNING: This system is **explicitly designed NOT to care about ordering**. Any order seen in this set has NO - * significance and should not be relied on. + * Note: This system is designed to care only about item balances. While you can usually assume that the actions + * are provided in the correct order, it will still successfully complete transactions whose actions are provided in + * the "wrong" order, as long as the transaction balances. + * For example, you may see that an action setting a slot to a particular item may appear before the action that + * removes that item from its original slot. While unintuitive, this is still valid. * * @return InventoryAction[] * @phpstan-return array @@ -119,19 +122,6 @@ class InventoryTransaction{ } } - /** - * Shuffles actions in the transaction to prevent external things relying on any implicit ordering. - */ - private function shuffleActions() : void{ - $keys = array_keys($this->actions); - shuffle($keys); - $actions = []; - foreach($keys as $key){ - $actions[$key] = $this->actions[$key]; - } - $this->actions = $actions; - } - /** * @param Item[] $needItems * @param Item[] $haveItems @@ -308,8 +298,6 @@ class InventoryTransaction{ throw new TransactionValidationException("Transaction has already been executed"); } - $this->shuffleActions(); - $this->validate(); if(!$this->callExecuteEvent()){