Fix translation service at setup

This commit is contained in:
Pig Fang 2019-11-13 14:27:22 +08:00
parent 8958cf489b
commit 200a5b2352
2 changed files with 10 additions and 2 deletions

View File

@ -11,7 +11,15 @@ class RedirectToSetup
public function handle($request, Closure $next)
{
$version = config('app.version');
if (! $request->is('setup*') && Comparator::greaterThan($version, option('version', $version))) {
$hasLock = resolve(Filesystem::class)->exists(storage_path('install.lock'));
// If lock isn't existed, it means that BS isn't installed.
// Database is unavailable at this time, so we should disable the loader.
if (! $hasLock) {
config(['translation-loader.translation_loaders' => []]);
}
if ($hasLock && ! $request->is('setup*') && Comparator::greaterThan($version, option('version', $version))) {
$user = $request->user();
if ($user && $user->isAdmin()) {
return redirect('/setup/update');
@ -20,7 +28,6 @@ class RedirectToSetup
}
}
$hasLock = resolve(Filesystem::class)->exists(storage_path('install.lock'));
if ($hasLock || $request->is('setup*')) {
return $next($request);
}

View File

@ -32,5 +32,6 @@ class RedirectToSetupTest extends TestCase
$this->get('/')->assertViewIs('home');
$this->get('/setup')->assertViewIs('setup.wizard.welcome');
$this->get('/')->assertRedirect('/setup');
$this->assertEquals([], config('translation-loader.translation_loaders'));
}
}