From 8ce0863559ba9b5a0dff364b36e8dd3b6392c268 Mon Sep 17 00:00:00 2001 From: Dane Everitt Date: Sat, 30 Dec 2017 20:53:34 -0600 Subject: [PATCH] Fix settings service provider to actually work when no migrations have been run. --- .env.example | 2 -- CHANGELOG.md | 1 + app/Providers/SettingsServiceProvider.php | 17 +++++++++++++---- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/.env.example b/.env.example index beabc0b09..e6eba87e0 100644 --- a/.env.example +++ b/.env.example @@ -27,5 +27,3 @@ MAIL_FROM=no-reply@example.com QUEUE_HIGH=high QUEUE_STANDARD=standard QUEUE_LOW=low - -APP_SERVICE_AUTHOR=undefined@example.com diff --git a/CHANGELOG.md b/CHANGELOG.md index fd6c1de41..fa25d0db9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ This project follows [Semantic Versioning](http://semver.org) guidelines. * `[beta.3]` — Fixes a bug with the default environment file that was causing an inability to perform a fresh install when running package discovery. * `[beta.3]` — Fixes an edge case caused by the Laravel 5.5 upgrade that would try to perform an in_array check aganist a null value. * `[beta.3]` — Fixes a bug that would cause an error when attempting to create a new user on the Panel. +* `[beta.3]` — Fixes error handling of the settings service provider when no migrations have been run. ## v0.7.0-beta.3 (Derelict Dermodactylus) ### Fixed diff --git a/app/Providers/SettingsServiceProvider.php b/app/Providers/SettingsServiceProvider.php index 060b13880..1b9596d80 100644 --- a/app/Providers/SettingsServiceProvider.php +++ b/app/Providers/SettingsServiceProvider.php @@ -2,6 +2,8 @@ namespace Pterodactyl\Providers; +use Illuminate\Contracts\Logging\Log; +use Illuminate\Database\QueryException; use Illuminate\Support\ServiceProvider; use Illuminate\Contracts\Encryption\Encrypter; use Illuminate\Contracts\Encryption\DecryptException; @@ -60,9 +62,10 @@ class SettingsServiceProvider extends ServiceProvider * * @param \Illuminate\Contracts\Config\Repository $config * @param \Illuminate\Contracts\Encryption\Encrypter $encrypter + * @param \Illuminate\Contracts\Logging\Log $log * @param \Pterodactyl\Contracts\Repository\SettingsRepositoryInterface $settings */ - public function boot(ConfigRepository $config, Encrypter $encrypter, SettingsRepositoryInterface $settings) + public function boot(ConfigRepository $config, Encrypter $encrypter, Log $log, SettingsRepositoryInterface $settings) { // Only set the email driver settings from the database if we // are configured using SMTP as the driver. @@ -70,9 +73,15 @@ class SettingsServiceProvider extends ServiceProvider $this->keys = array_merge($this->keys, $this->emailKeys); } - $values = $settings->all()->mapWithKeys(function ($setting) { - return [$setting->key => $setting->value]; - })->toArray(); + try { + $values = $settings->all()->mapWithKeys(function ($setting) { + return [$setting->key => $setting->value]; + })->toArray(); + } catch (QueryException $exception) { + $log->notice('A query exception was encountered while trying to load settings from the database.'); + + return; + } foreach ($this->keys as $key) { $value = array_get($values, 'settings::' . $key, $config->get(str_replace(':', '.', $key)));