diff --git a/app/Helpers/Update/UpdateTrait.php b/app/Helpers/Update/UpdateTrait.php index dc3610ee07..9ac6dc2b2f 100644 --- a/app/Helpers/Update/UpdateTrait.php +++ b/app/Helpers/Update/UpdateTrait.php @@ -43,8 +43,9 @@ trait UpdateTrait { Log::debug('Now in getLatestRelease()'); /** @var UpdateRequestInterface $checker */ - $checker = app(UpdateRequestInterface::class); - $channel = app('fireflyconfig')->get('update_channel', 'stable')->data; + $checker = app(UpdateRequestInterface::class); + $channelConfig = app('fireflyconfig')->get('update_channel', 'stable'); + $channel = $channelConfig ? $channelConfig->data : 'stable'; return $checker->getUpdateInformation($channel); } diff --git a/app/Http/Controllers/Controller.php b/app/Http/Controllers/Controller.php index a54c40afba..79434b738c 100644 --- a/app/Http/Controllers/Controller.php +++ b/app/Http/Controllers/Controller.php @@ -55,7 +55,8 @@ class Controller extends BaseController public function __construct() { // is site a demo site? - $isDemoSite = app('fireflyconfig')->get('is_demo_site', config('firefly.configuration.is_demo_site', false,),)->data; + $isDemoSiteConfig = app('fireflyconfig')->get('is_demo_site', config('firefly.configuration.is_demo_site', false,),); + $isDemoSite = $isDemoSiteConfig ? $isDemoSiteConfig->data : false; app('view')->share('IS_DEMO_SITE', $isDemoSite,); app('view')->share('DEMO_USERNAME', config('firefly.demo_username')); app('view')->share('DEMO_PASSWORD', config('firefly.demo_password')); diff --git a/app/Http/Controllers/DebugController.php b/app/Http/Controllers/DebugController.php index e77f40c4ba..d6055e4da2 100644 --- a/app/Http/Controllers/DebugController.php +++ b/app/Http/Controllers/DebugController.php @@ -121,25 +121,26 @@ class DebugController extends Controller $search = ['~', '#']; $replace = ['\~', '# ']; - $now = Carbon::now()->format('Y-m-d H:i:s e'); - $installationId = app('fireflyconfig')->get('installation_id', '')->data; - $phpVersion = str_replace($search, $replace, PHP_VERSION); - $phpOs = str_replace($search, $replace, PHP_OS); - $interface = PHP_SAPI; - $drivers = implode(', ', DB::availableDrivers()); - $currentDriver = DB::getDriverName(); - $userAgent = $request->header('user-agent'); - $trustedProxies = config('firefly.trusted_proxies'); - $displayErrors = ini_get('display_errors'); - $errorReporting = $this->errorReporting((int) ini_get('error_reporting')); - $appEnv = config('app.env'); - $appDebug = var_export(config('app.debug'), true); - $logChannel = config('logging.default'); - $appLogLevel = config('logging.level'); - $cacheDriver = config('cache.default'); - $loginProvider = config('auth.providers.users.driver'); - $bcscale = bcscale(); - $layout = env('FIREFLY_III_LAYOUT'); + $now = Carbon::now()->format('Y-m-d H:i:s e'); + $installationIdConfig = app('fireflyconfig')->get('installation_id', ''); + $installationId = $installationIdConfig ? $installationIdConfig->data : ''; + $phpVersion = str_replace($search, $replace, PHP_VERSION); + $phpOs = str_replace($search, $replace, PHP_OS); + $interface = PHP_SAPI; + $drivers = implode(', ', DB::availableDrivers()); + $currentDriver = DB::getDriverName(); + $userAgent = $request->header('user-agent'); + $trustedProxies = config('firefly.trusted_proxies'); + $displayErrors = ini_get('display_errors'); + $errorReporting = $this->errorReporting((int) ini_get('error_reporting')); + $appEnv = config('app.env'); + $appDebug = var_export(config('app.debug'), true); + $logChannel = config('logging.default'); + $appLogLevel = config('logging.level'); + $cacheDriver = config('cache.default'); + $loginProvider = config('auth.providers.users.driver'); + $bcscale = bcscale(); + $layout = env('FIREFLY_III_LAYOUT'); // some new vars. $telemetry = true === config('firefly.send_telemetry') && true === config('firefly.feature_flags.telemetry'); diff --git a/app/Support/FireflyConfig.php b/app/Support/FireflyConfig.php index b8a96a0529..2c05be6cae 100644 --- a/app/Support/FireflyConfig.php +++ b/app/Support/FireflyConfig.php @@ -24,6 +24,7 @@ namespace FireflyIII\Support; use Cache; use Exception; +use FireflyIII\Exceptions\FireflyException; use FireflyIII\Models\Configuration; use Illuminate\Database\QueryException; use Log; @@ -67,9 +68,10 @@ class FireflyConfig /** * @param string $name - * @param mixed $default + * @param null $default * - * @return \FireflyIII\Models\Configuration|null + * @throws FireflyException + * @return Configuration|null */ public function get(string $name, $default = null): ?Configuration { @@ -82,10 +84,12 @@ class FireflyConfig } try { + /** @var Configuration $config */ $config = Configuration::where('name', $name)->first(['id', 'name', 'data']); } catch (QueryException|Exception $e) { Log::error(sprintf('Query exception while polling for config var: %s', $e->getMessage())); - return null; + Log::error($e->getTraceAsString()); + throw new FireflyException(sprintf('Could not poll the database: %s', $e->getMessage())); } if ($config) {