Skip to content

Commit

Permalink
InventoryAction: avoid throwaway Item clones
Browse files Browse the repository at this point in the history
  • Loading branch information
dktapps committed Feb 16, 2025
1 parent 2670e81 commit 246c177
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/inventory/transaction/InventoryTransaction.php
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,9 @@ protected function matchItems(array &$needItems, array &$haveItems) : void{
$needItems = [];
$haveItems = [];
foreach($this->actions as $key => $action){
if(!$action->getTargetItem()->isNull()){
$needItems[] = $action->getTargetItem();
$targetItem = $action->getTargetItem();
if(!$targetItem->isNull()){
$needItems[] = $targetItem;
}

try{
Expand All @@ -154,8 +155,9 @@ protected function matchItems(array &$needItems, array &$haveItems) : void{
throw new TransactionValidationException(get_class($action) . "#" . spl_object_id($action) . ": " . $e->getMessage(), 0, $e);
}

if(!$action->getSourceItem()->isNull()){
$haveItems[] = $action->getSourceItem();
$sourceItem = $action->getSourceItem();
if(!$sourceItem->isNull()){
$haveItems[] = $sourceItem;
}
}

Expand Down

0 comments on commit 246c177

Please sign in to comment.