From e0a8d4cb3e9bb0e40c413a0aaa4723ca2f10033e Mon Sep 17 00:00:00 2001 From: Pig Fang Date: Mon, 18 Mar 2019 17:57:20 +0800 Subject: [PATCH] Fix --- .env.example | 6 ++---- app/Http/Controllers/SetupController.php | 16 ---------------- app/Http/Middleware/CheckInstallation.php | 4 ++++ app/Providers/RuntimeCheckServiceProvider.php | 2 +- config/database.php | 5 +++++ tests/MiddlewareTest.php | 7 ------- 6 files changed, 12 insertions(+), 28 deletions(-) diff --git a/.env.example b/.env.example index dbe6505e..1178c176 100644 --- a/.env.example +++ b/.env.example @@ -11,10 +11,10 @@ APP_DEBUG = false APP_ENV = production # Database Configuration -DB_CONNECTION = mysql +DB_CONNECTION = dummy DB_HOST = localhost DB_PORT = 3306 -DB_DATABASE = blessing-skin +DB_DATABASE = blessingskin DB_USERNAME = username DB_PASSWORD = secret # ========================= @@ -52,8 +52,6 @@ SALT = 2c5ca184f017a9a1ffbd198ef69b0c0e # APP_KEY = base64:gkb/zouNF6UOSfnr/o+izVMS57WQS3+62YqZBuDyBhU= -FIRST_RUN = true - # Mail Configuration # # Leave MAIL_DRIVER empty to disable features involving sending emails. diff --git a/app/Http/Controllers/SetupController.php b/app/Http/Controllers/SetupController.php index e316ee6f..ba49abb7 100644 --- a/app/Http/Controllers/SetupController.php +++ b/app/Http/Controllers/SetupController.php @@ -261,26 +261,10 @@ class SetupController extends Controller */ public static function checkTablesExist($tables = [], $returnExistingTables = false) { - if (request()->is('setup') || request()->is('setup/database')) { - // We're ready to install Blessing Skin, so skip the checks. - try { - DB::connection(env('DB_CONNECTION'))->getPdo(); - } catch (\Exception $e) { - return false; - } - } - - // @codeCoverageIgnoreStart - if (env('FIRST_RUN') && request()->is('/')) { - return false; - } - // @codeCoverageIgnoreEnd - $existingTables = []; $tables = $tables ?: ['users', 'user_closet', 'players', 'textures', 'options']; foreach ($tables as $tableName) { - // Table prefix will be added automatically if (Schema::hasTable($tableName)) { $existingTables[] = $tableName; } diff --git a/app/Http/Middleware/CheckInstallation.php b/app/Http/Middleware/CheckInstallation.php index 3469c972..23ed89b2 100644 --- a/app/Http/Middleware/CheckInstallation.php +++ b/app/Http/Middleware/CheckInstallation.php @@ -8,6 +8,10 @@ class CheckInstallation { public function handle($request, \Closure $next) { + if (env('DB_CONNECTION') == 'dummy') { + return $next($request); + } + if (SetupController::checkTablesExist()) { return response()->view('setup.locked'); } diff --git a/app/Providers/RuntimeCheckServiceProvider.php b/app/Providers/RuntimeCheckServiceProvider.php index fb519ea8..3117ae5b 100644 --- a/app/Providers/RuntimeCheckServiceProvider.php +++ b/app/Providers/RuntimeCheckServiceProvider.php @@ -33,7 +33,7 @@ class RuntimeCheckServiceProvider extends ServiceProvider protected function checkInstallation() { // Redirect to setup wizard - if (! SetupController::checkTablesExist()) { + if (env('DB_CONNECTION') == 'dummy' || ! SetupController::checkTablesExist()) { return redirect('/setup')->send(); } diff --git a/config/database.php b/config/database.php index 42a37690..091b280c 100644 --- a/config/database.php +++ b/config/database.php @@ -78,6 +78,11 @@ return [ 'schema' => 'public', ], + 'dummy' => [ + 'driver' => 'sqlite', + 'database' => '', + ], + ], /* diff --git a/tests/MiddlewareTest.php b/tests/MiddlewareTest.php index baed70fd..8717a284 100644 --- a/tests/MiddlewareTest.php +++ b/tests/MiddlewareTest.php @@ -118,13 +118,6 @@ class MiddlewareTest extends TestCase 'setup.wizard.welcome.text', ['version' => config('app.version')] )); - - DB::shouldReceive('connection')->once()->andThrow(new \Exception('fake exception')); - DB::shouldReceive('disconnect')->andReturnSelf(); - $this->get('/setup')->assertSee(trans( - 'setup.wizard.welcome.text', - ['version' => config('app.version')] - )); } public function testCheckPlayerExist()