mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-12 15:35:15 +00:00
Stop using "db_version", check versions instead.
This commit is contained in:
@@ -26,6 +26,8 @@ namespace FireflyIII\Http\Middleware;
|
||||
|
||||
use Closure;
|
||||
use FireflyIII\Exceptions\FireflyException;
|
||||
use FireflyIII\Support\FireflyConfig;
|
||||
use FireflyIII\Support\System\IsOldVersion;
|
||||
use FireflyIII\Support\System\OAuthKeys;
|
||||
use Illuminate\Database\QueryException;
|
||||
use Illuminate\Http\Request;
|
||||
@@ -37,6 +39,7 @@ use Illuminate\Support\Facades\Log;
|
||||
*/
|
||||
class Installer
|
||||
{
|
||||
use IsOldVersion;
|
||||
/**
|
||||
* Handle an incoming request.
|
||||
*
|
||||
@@ -65,7 +68,7 @@ class Installer
|
||||
// run installer when no tables are present,
|
||||
// or when old scheme version
|
||||
// or when old firefly version
|
||||
if ($this->hasNoTables() || $this->oldDBVersion() || $this->oldVersion()) {
|
||||
if ($this->hasNoTables() || $this->isOldVersionInstalled()) {
|
||||
return response()->redirectTo(route('installer.index'));
|
||||
}
|
||||
OAuthKeys::verifyKeysRoutine();
|
||||
@@ -126,59 +129,4 @@ class Installer
|
||||
{
|
||||
return false !== stripos($message, 'Base table or view not found');
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the "db_version" variable is correct.
|
||||
*/
|
||||
private function oldDBVersion(): bool
|
||||
{
|
||||
// older version in config than database?
|
||||
$configVersion = (int) config('firefly.db_version');
|
||||
$dbVersion = (int) app('fireflyconfig')->getFresh('db_version', 1)->data;
|
||||
if ($configVersion > $dbVersion) {
|
||||
Log::warning(
|
||||
sprintf(
|
||||
'The current configured version (%d) is older than the required version (%d). Redirect to migrate routine.',
|
||||
$dbVersion,
|
||||
$configVersion
|
||||
)
|
||||
);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// Log::info(sprintf('Configured DB version (%d) equals expected DB version (%d)', $dbVersion, $configVersion));
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the "firefly_version" variable is correct.
|
||||
*/
|
||||
private function oldVersion(): bool
|
||||
{
|
||||
// version compare thing.
|
||||
$configVersion = (string) config('firefly.version');
|
||||
$dbVersion = (string) app('fireflyconfig')->getFresh('ff3_version', '1.0')->data;
|
||||
if (str_starts_with($configVersion, 'develop')) {
|
||||
Log::debug('Skipping version check for develop version.');
|
||||
|
||||
return false;
|
||||
}
|
||||
if (1 === version_compare($configVersion, $dbVersion)) {
|
||||
Log::warning(
|
||||
sprintf(
|
||||
'The current configured Firefly III version (%s) is older than the required version (%s). Redirect to migrate routine.',
|
||||
$dbVersion,
|
||||
$configVersion
|
||||
)
|
||||
);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// Log::info(sprintf('Installed Firefly III version (%s) equals expected Firefly III version (%s)', $dbVersion, $configVersion));
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user