From 789e6a52911b21ed05385267a4d930ae3265341d Mon Sep 17 00:00:00 2001 From: Bernd Bestel Date: Thu, 6 Jan 2022 14:36:35 +0100 Subject: [PATCH] Don't crash the recipes page when the amount contains user-desired (and manually edited) bullshit (fixes #1691) --- views/recipeform.blade.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/views/recipeform.blade.php b/views/recipeform.blade.php index b9792f9c..27275fd6 100644 --- a/views/recipeform.blade.php +++ b/views/recipeform.blade.php @@ -174,6 +174,15 @@ @php + // The amount can't be non-numeric when using the frontend, + // but some users decide to edit the database manually and + // enter something like "4 or 5" in the amount column (brilliant) + // => So at least don't crash this view by just assuming 0 if that's the case + if (!is_numeric($recipePosition->amount)) + { + $recipePosition->amount = 0; + } + $product = FindObjectInArrayByPropertyValue($products, 'id', $recipePosition->product_id); $productQuConversions = FindAllObjectsInArrayByPropertyValue($quantityUnitConversionsResolved, 'product_id', $product->id); $productQuConversions = FindAllObjectsInArrayByPropertyValue($productQuConversions, 'from_qu_id', $product->qu_id_stock);