- π©πͺGermany Anybody Porta Westfalica
Eventually checking for
commerce_price
might be more solid?
See https://git.drupalcode.org/project/commerce_reports/-/blob/8.x-1.x/comme... implementations. - π¬π§United Kingdom dahousecat
I just encountered this issue and found that the SimpleMathField class is a bit flakey.
getFieldValue says it returns mixed, but then the return value is used by functions like preg_match and strpos without first checking the type.
I suspect really getFieldValue should define it's return type as string and probably log an error if it tries to return something that is not.
However I've just gone for a very light refactor in this patch introducing these changes:
- In removeSeparator if $data is not string just return $data.
- Re-write the whole part where if it's a commerce price field.
- Add an additional is_string check before calling preg_match.It looks like the patch from ivanpg94 would also fix this bug but I only came across this ticket once I'd already written my own patch, which does include some additional safety checks.
- πΊπΈUnited States andileco
Hi all, I don't use Commerce myself, and so testing this always proves to be a big hassle. This ticket is also marked for 8.x-1.x, which is two versions back. @dahousecat is your patch for 3.0.x? If so, please update the ticket. If someone can provide some steps to repeat and test the patch, I would appreciate it.