Only try to retrieve the targetLot from DB if the parameter is existing

This fixes an excpetion occuring during withdrawal of parts, when moving is disabled for the lot.
This commit is contained in:
Jan Böhmer 2023-04-16 01:22:58 +02:00
parent 0dcdd252f5
commit 37fb895d67

View file

@ -350,8 +350,10 @@ class PartController extends AbstractController
if($partLot->getPart() !== $part) { if($partLot->getPart() !== $part) {
throw new \RuntimeException("The origin partlot does not belong to the part!"); throw new \RuntimeException("The origin partlot does not belong to the part!");
} }
//Try to determine the target lot (used for move actions)
$targetLot = $em->find(PartLot::class, $request->request->get('target_id')); //Try to determine the target lot (used for move actions), if the parameter is existing
$targetId = $request->request->get('target_id', null);
$targetLot = $targetId ? $em->find(PartLot::class, $targetId) : null;
if ($targetLot && $targetLot->getPart() !== $part) { if ($targetLot && $targetLot->getPart() !== $part) {
throw new \RuntimeException("The target partlot does not belong to the part!"); throw new \RuntimeException("The target partlot does not belong to the part!");
} }