Firefly III: a personal finances manager
PHP accountingbudgetbudgetingbudgetscash-flowcashflowcredit-carddockerexpensesfinancefinancesfinanciallinuxmoneypaycheckpersonal-financephpphp7
Fixes #2125
James Cole61db41948513
diff --git a/app/Console/Commands/UpgradeDatabase.php b/app/Console/Commands/UpgradeDatabase.phpindex 9a5cbeaf37..b3f4c3cac6 100644--- a/app/Console/Commands/UpgradeDatabase.php+++ b/app/Console/Commands/UpgradeDatabase.php@@ -28,6 +28,7 @@ declare(strict_types=1);namespace FireflyIII\Console\Commands;+use Crypt;use DB;use Exception;use FireflyIII\Models\Account;@@ -53,6 +54,7 @@ use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface;use FireflyIII\Repositories\Journal\JournalRepositoryInterface;use FireflyIII\User;use Illuminate\Console\Command;+use Illuminate\Contracts\Encryption\DecryptException;use Illuminate\Database\QueryException;use Illuminate\Support\Collection;use Log;@@ -106,6 +108,22 @@ class UpgradeDatabase extends Commandreturn 0;}+ /**+ * @param string $value+ *+ * @return string+ */+ private function tryDecrypt(string $value): string+ {+ try {+ $value = Crypt::decrypt($value);+ } catch (DecryptException $e) {+ Log::debug(sprintf('Could not decrypt. %s', $e->getMessage()));+ }++ return $value;+ }+/*** Since it is one routine these warnings make sense and should be supressed.*@@ -127,8 +145,9 @@ class UpgradeDatabase extends Commandreturn;}+ $currencyCode = $this->tryDecrypt($currencyPreference->data);- $currency = TransactionCurrency::where('code', $currencyPreference->data)->first();+ $currency = TransactionCurrency::where('code', $currencyCode)->first();if (null === $currency) {$this->line('Fall back to default currency in migrateBillsToRules().');$currency = app('amount')->getDefaultCurrencyByUser($user);