From de5cb4c1650b6d5b55870742ebdb6cfa3064fda1 Mon Sep 17 00:00:00 2001 From: James Cole Date: Wed, 27 Dec 2023 19:36:28 +0100 Subject: [PATCH] Catch division by zero. https://github.com/firefly-iii/firefly-iii/issues/8297 --- app/Support/Http/Api/ExchangeRateConverter.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/Support/Http/Api/ExchangeRateConverter.php b/app/Support/Http/Api/ExchangeRateConverter.php index ee94070233..c64e8f34e3 100644 --- a/app/Support/Http/Api/ExchangeRateConverter.php +++ b/app/Support/Http/Api/ExchangeRateConverter.php @@ -156,7 +156,7 @@ class ExchangeRateConverter // perhaps the rate has been cached during this particular run $preparedRate = $this->prepared[$date][$from][$to] ?? null; - if (null !== $preparedRate && '0' !== $preparedRate) { + if (null !== $preparedRate && 0 !== bccomp('0', $preparedRate)) { return $preparedRate; } @@ -187,7 +187,7 @@ class ExchangeRateConverter if ('' === $rate) { return null; } - if('0' === $rate) { + if (0 === bccomp('0', $preparedRate)) { return null; }