InventoryAction: avoid throwaway Item clones

This commit is contained in:
Dylan K. Taylor 2025-02-16 21:47:35 +00:00
parent 2670e81668
commit 246c1776df
No known key found for this signature in database
GPG Key ID: 8927471A91CAFD3D

View File

@ -144,8 +144,9 @@ class InventoryTransaction{
$needItems = []; $needItems = [];
$haveItems = []; $haveItems = [];
foreach($this->actions as $key => $action){ foreach($this->actions as $key => $action){
if(!$action->getTargetItem()->isNull()){ $targetItem = $action->getTargetItem();
$needItems[] = $action->getTargetItem(); if(!$targetItem->isNull()){
$needItems[] = $targetItem;
} }
try{ try{
@ -154,8 +155,9 @@ class InventoryTransaction{
throw new TransactionValidationException(get_class($action) . "#" . spl_object_id($action) . ": " . $e->getMessage(), 0, $e); throw new TransactionValidationException(get_class($action) . "#" . spl_object_id($action) . ": " . $e->getMessage(), 0, $e);
} }
if(!$action->getSourceItem()->isNull()){ $sourceItem = $action->getSourceItem();
$haveItems[] = $action->getSourceItem(); if(!$sourceItem->isNull()){
$haveItems[] = $sourceItem;
} }
} }