fix @MayNiklas reported bug: when manually submitting the form (from a barcode scan or manual input) redirect to Create New part screen for the decoded information instead of showing 'Format Unknown' popup error message

This commit is contained in:
swdee 2026-02-18 21:53:54 +13:00
parent 4881418af3
commit 2d55b90311

View file

@ -100,8 +100,19 @@ class ScanController extends AbstractController
// If not in info mode, mimic “normal scan” behavior: redirect if possible.
if (!$infoMode) {
$url = $this->barcodeParser->getRedirectURL($scan);
return $this->redirect($url);
try {
$url = $this->barcodeParser->getRedirectURL($scan);
return $this->redirect($url);
} catch (EntityNotFoundException) {
// Decoded OK, but no part is found. If its a vendor code, redirect to create.
$createUrl = $this->buildCreateUrlForScanResult($scan, $request->getLocale());
if ($createUrl !== null) {
return $this->redirect($createUrl);
}
// Otherwise: show “not found” (not “format unknown”)
$this->addFlash('warning', 'scan.qr_not_found');
}
}
// Info mode fallback: render page with prefilled result