This commit is contained in:
Pig Fang 2019-03-18 17:57:20 +08:00
parent d06e17dfdc
commit e0a8d4cb3e
6 changed files with 12 additions and 28 deletions

View File

@ -11,10 +11,10 @@ APP_DEBUG = false
APP_ENV = production APP_ENV = production
# Database Configuration # Database Configuration
DB_CONNECTION = mysql DB_CONNECTION = dummy
DB_HOST = localhost DB_HOST = localhost
DB_PORT = 3306 DB_PORT = 3306
DB_DATABASE = blessing-skin DB_DATABASE = blessingskin
DB_USERNAME = username DB_USERNAME = username
DB_PASSWORD = secret DB_PASSWORD = secret
# ========================= # =========================
@ -52,8 +52,6 @@ SALT = 2c5ca184f017a9a1ffbd198ef69b0c0e
# #
APP_KEY = base64:gkb/zouNF6UOSfnr/o+izVMS57WQS3+62YqZBuDyBhU= APP_KEY = base64:gkb/zouNF6UOSfnr/o+izVMS57WQS3+62YqZBuDyBhU=
FIRST_RUN = true
# Mail Configuration # Mail Configuration
# #
# Leave MAIL_DRIVER empty to disable features involving sending emails. # Leave MAIL_DRIVER empty to disable features involving sending emails.

View File

@ -261,26 +261,10 @@ class SetupController extends Controller
*/ */
public static function checkTablesExist($tables = [], $returnExistingTables = false) 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 = []; $existingTables = [];
$tables = $tables ?: ['users', 'user_closet', 'players', 'textures', 'options']; $tables = $tables ?: ['users', 'user_closet', 'players', 'textures', 'options'];
foreach ($tables as $tableName) { foreach ($tables as $tableName) {
// Table prefix will be added automatically
if (Schema::hasTable($tableName)) { if (Schema::hasTable($tableName)) {
$existingTables[] = $tableName; $existingTables[] = $tableName;
} }

View File

@ -8,6 +8,10 @@ class CheckInstallation
{ {
public function handle($request, \Closure $next) public function handle($request, \Closure $next)
{ {
if (env('DB_CONNECTION') == 'dummy') {
return $next($request);
}
if (SetupController::checkTablesExist()) { if (SetupController::checkTablesExist()) {
return response()->view('setup.locked'); return response()->view('setup.locked');
} }

View File

@ -33,7 +33,7 @@ class RuntimeCheckServiceProvider extends ServiceProvider
protected function checkInstallation() protected function checkInstallation()
{ {
// Redirect to setup wizard // Redirect to setup wizard
if (! SetupController::checkTablesExist()) { if (env('DB_CONNECTION') == 'dummy' || ! SetupController::checkTablesExist()) {
return redirect('/setup')->send(); return redirect('/setup')->send();
} }

View File

@ -78,6 +78,11 @@ return [
'schema' => 'public', 'schema' => 'public',
], ],
'dummy' => [
'driver' => 'sqlite',
'database' => '',
],
], ],
/* /*

View File

@ -118,13 +118,6 @@ class MiddlewareTest extends TestCase
'setup.wizard.welcome.text', 'setup.wizard.welcome.text',
['version' => config('app.version')] ['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() public function testCheckPlayerExist()