New site, so I don't what is wrong.

This crashes when saved, and you can see it's go 1 0/1 in the line. The error is:

TypeError: round(): Argument #1 ($num) must be of type int|float, string given in round() (line 157 of /home/thesite.com/dev/web/modules/contrib/recipe/modules/ingredient/src/Plugin/Field/FieldWidget/IngredientWidget.php)

Ingredients
1⁄2 c cashews (raw and unsalted)
1⁄2 bn cilantro
1 0⁄1 lime
1 0⁄1 jalapeno pepper
5 0⁄1 clv garlic
CommentFileSizeAuthor
#4 3226184-1.patch901 bytesokuegler

Comments

tresero created an issue. See original summary.

dcam’s picture

What values did you attempt to enter into the ingredient field to get these results? Were you entering these values as you've written above?

tresero’s picture

Sorry, I was never notified of a response. I don't have that site anymore, but am building a new one so I'll check in the next few days.

okuegler’s picture

StatusFileSize
new901 bytes

I had a similar issue. For me it crashed when the ingredient quantity was not entered. The problem is that the getQuantityFromFraction function in this case returns an empty string, which crashed the round function in massageFormValues on line 157 of IngredientWidget.php. I created a patch that should always return a number, not a string.

Webbeh’s picture

Status: Active » Needs review

Per #4.

Webbeh’s picture

Title: Crash » TypeError: round(): Argument #1 ($num) must be of type int|float, string given in round()
soubi’s picture

#4 works on Drupal 9.4.2

dcam’s picture

I should have guessed that this is a PHP 8.x problem. I ran into it after I started trying to upgrade the module for D10 because it requires PHP 8. The errors in the PHP 8 test that I ran are unrelated and will be dealt with in the D10 patch. Thank you @okuegler for supplying a patch!

  • dcam committed 06cbb09 on 8.x-2.x
    Issue #3226184 by okuegler: TypeError: round(): Argument #1 ($num) must...
dcam’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.