This takes the first  uninterrupted string of numbers as the correct yield count.
This commit is contained in:
Linard Schwendener 2019-11-27 00:20:52 +01:00
Родитель 692e729b90
Коммит 7d99d11648
1 изменённых файлов: 6 добавлений и 1 удалений

Просмотреть файл

@ -168,7 +168,12 @@ class RecipeService
// Make sure that "recipeYield" is an integer which is at least 1
if (isset($json['recipeYield']) && $json['recipeYield']) {
$yield = filter_var($json['recipeYield'], FILTER_SANITIZE_NUMBER_INT);
$regex_matches = [];
preg_match('/^.*?(\d*)/', $json['recipeYield'], $regex_matches);
if (count($regex_matches) >= 1 ){
$yield = filter_var($regex_matches[0], FILTER_SANITIZE_NUMBER_INT);
}
if ($yield && $yield > 0) {
$json['recipeYield'] = (int)$yield;