- Affected version
- 2.2.12
Hello.
The issue was discussing here.
Where is the problem?
Language.php, function currencyFormat.
In XF 2.1.2 it was
In XF 2.2.12 became
This one
Why it should be fixed as was before?
1. Even
2. Incorrect use of some currencies, because there is a sufficient list of 1/1000 currencies - Bahraini dinar, Kuwaiti dinar, Omani rial, Tunisian dinar, Japanese rin and so on https://en.wikipedia.org/wiki/List_of_circulating_currencies
3. Now it's impossible to use cryptocurrency. Bitcoin, Ethereum and so on. Min available value now is 0.01, 0.01 bitcoin equals 220$ (unrealistic value for everyday use). No ability to format this value into custom view.
I suggest to return as it was before. Or to fix this bug.
Thanks!
The issue was discussing here.
XF\Language::currencyFormat
method now returns only fixed (two) decimal places despite the argument passed. Now it's impossible to format this value and change into custom view. I.e. 0.12345
. It worked fine till late XF 2.1.x versions. Than in last 2.2.x versions seems something changes and this function stopped work correctly.Where is the problem?
Language.php, function currencyFormat.
In XF 2.1.2 it was
PHP:
public function currencyFormat($value, $symbol, $precision = 2, $format = null)
{
$format = $format ?: $this->options['currency_format'];
return strtr($format, [
'{symbol}' => $symbol,
'{value}' => $this->numberFormat($value, $precision)
]);
}
PHP:
public function currencyFormat($value, $symbol, $desiredPrecision = 2, $format = null): string
{
if ($value === null)
{
$value = 0;
}
if (!is_integer($value) && floor($value) !== $value)
{
// don't hide a decimal if we have one
$desiredPrecision = 2;
}
$format = $format ?: $this->options['currency_format'];
return strtr($format, [
'{symbol}' => $symbol,
'{value}' => $this->numberFormat($value, $desiredPrecision)
]);
}
PHP:
if (!is_integer($value) && floor($value) !== $value)
{
// don't hide a decimal if we have one
$desiredPrecision = 2;
}
Why it should be fixed as was before?
1. Even
XF\Data\Currency
currencies not dispayed correctly. For example VND (Vietnamese Dong).2. Incorrect use of some currencies, because there is a sufficient list of 1/1000 currencies - Bahraini dinar, Kuwaiti dinar, Omani rial, Tunisian dinar, Japanese rin and so on https://en.wikipedia.org/wiki/List_of_circulating_currencies
3. Now it's impossible to use cryptocurrency. Bitcoin, Ethereum and so on. Min available value now is 0.01, 0.01 bitcoin equals 220$ (unrealistic value for everyday use). No ability to format this value into custom view.
I suggest to return as it was before. Or to fix this bug.
Thanks!
Last edited: