mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-22 03:53:37 +00:00
Fixes #2125
This commit is contained in:
@@ -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 Command
|
||||
return 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 Command
|
||||
|
||||
return;
|
||||
}
|
||||
$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);
|
||||
|
Reference in New Issue
Block a user