Bcmul warning when exchange rate is in scientific notation

Created on 18 May 2022, over 2 years ago
Updated 15 October 2024, about 1 month ago

Problem/Motivation

Error message: Warning: bcmul(): bcmath function argument is not well-formed in Drupal\commerce_price\Calculator::multiply() (line 75 of modules\contrib\commerce\modules\price\src\Calculator.php)
when exchange rate from ECB is stored in scientific notation.

Steps to reproduce

Enable currencies USD and IDR. Try to convert 100 IDR to USD.

Proposed resolution

Perhaps a check and/or conversion of all exchange rates in file Drupal\commerce_exchanger\AbstractExchangerCalculator (line 91) before price conversion utilizing Drupal\commerce_price\Calculator::multiply().

This seems to work
$rate = sprintf('%f', floatval($rate));
However I'm not sure about any security implications this might have.

Remaining tasks

User interface changes

API changes

Data model changes

🐛 Bug report
Status

Closed: cannot reproduce

Version

1.20

Component

Code

Created by

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024