Code cleanup.

This commit is contained in:
James Cole
2023-12-20 19:35:52 +01:00
parent c4f6366642
commit 64ec0cf62e
997 changed files with 12908 additions and 28136 deletions

View File

@@ -24,7 +24,6 @@ declare(strict_types=1);
namespace FireflyIII\Http\Middleware;
use Closure;
use DB;
use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Support\System\OAuthKeys;
@@ -33,8 +32,6 @@ use Illuminate\Http\Request;
/**
* Class Installer
*
*
*/
class Installer
{
@@ -42,16 +39,14 @@ class Installer
* Handle an incoming request.
*
* @param Request $request
* @param Closure $next
*
* @return mixed
*
* @throws FireflyException
*
*/
public function handle($request, Closure $next)
public function handle($request, \Closure $next)
{
//app('log')->debug(sprintf('Installer middleware for URL %s', $request->url()));
// app('log')->debug(sprintf('Installer middleware for URL %s', $request->url()));
// ignore installer in test environment.
if ('testing' === config('app.env')) {
return $next($request);
@@ -60,7 +55,7 @@ class Installer
$url = $request->url();
$strpos = stripos($url, '/install');
if (false !== $strpos) {
//app('log')->debug(sprintf('URL is %s, will NOT run installer middleware', $url));
// app('log')->debug(sprintf('URL is %s, will NOT run installer middleware', $url));
return $next($request);
}
@@ -72,23 +67,39 @@ class Installer
return response()->redirectTo(route('installer.index'));
}
OAuthKeys::verifyKeysRoutine();
// update scheme version
// update firefly version
return $next($request);
}
/**
* Is access denied error.
*/
protected function isAccessDenied(string $message): bool
{
return false !== stripos($message, 'Access denied');
}
/**
* Is no tables exist error.
*/
protected function noTablesExist(string $message): bool
{
return false !== stripos($message, 'Base table or view not found');
}
/**
* Check if the tables are created and accounted for.
*
* @return bool
* @throws FireflyException
*/
private function hasNoTables(): bool
{
//app('log')->debug('Now in routine hasNoTables()');
// app('log')->debug('Now in routine hasNoTables()');
try {
DB::table('users')->count();
\DB::table('users')->count();
} catch (QueryException $e) {
$message = $e->getMessage();
app('log')->error(sprintf('Error message trying to access users-table: %s', $message));
@@ -105,42 +116,17 @@ class Installer
return true;
}
throw new FireflyException(sprintf('Could not access the database: %s', $message), 0, $e);
}
//app('log')->debug('Everything seems OK with the tables.');
// app('log')->debug('Everything seems OK with the tables.');
return false;
}
/**
* Is access denied error.
*
* @param string $message
*
* @return bool
*/
protected function isAccessDenied(string $message): bool
{
return false !== stripos($message, 'Access denied');
}
/**
* Is no tables exist error.
*
* @param string $message
*
* @return bool
*/
protected function noTablesExist(string $message): bool
{
return false !== stripos($message, 'Base table or view not found');
}
/**
* Check if the "db_version" variable is correct.
*
* @return bool
*/
private function oldDBVersion(): bool
{
@@ -159,15 +145,13 @@ class Installer
return true;
}
//app('log')->info(sprintf('Configured DB version (%d) equals expected DB version (%d)', $dbVersion, $configVersion));
// app('log')->info(sprintf('Configured DB version (%d) equals expected DB version (%d)', $dbVersion, $configVersion));
return false;
}
/**
* Check if the "firefly_version" variable is correct.
*
* @return bool
*/
private function oldVersion(): bool
{
@@ -186,7 +170,7 @@ class Installer
return true;
}
//app('log')->info(sprintf('Installed Firefly III version (%s) equals expected Firefly III version (%s)', $dbVersion, $configVersion));
// app('log')->info(sprintf('Installed Firefly III version (%s) equals expected Firefly III version (%s)', $dbVersion, $configVersion));
return false;
}