From 37fb895d67af9a357f92d020b215efd9bc964135 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20B=C3=B6hmer?= Date: Sun, 16 Apr 2023 01:22:58 +0200 Subject: [PATCH] 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. --- src/Controller/PartController.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Controller/PartController.php b/src/Controller/PartController.php index 019855b9..b7a3fd0e 100644 --- a/src/Controller/PartController.php +++ b/src/Controller/PartController.php @@ -350,8 +350,10 @@ class PartController extends AbstractController if($partLot->getPart() !== $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) { throw new \RuntimeException("The target partlot does not belong to the part!"); }