From 0b48f375dfb0ddc9a4ee921aefdf90c96712f72b Mon Sep 17 00:00:00 2001 From: ildyria Date: Tue, 1 Sep 2020 09:38:46 +0200 Subject: [PATCH 1/2] fix #708 --- app/Http/Controllers/DiagnosticsController.php | 4 +++- database/migrations/2018_08_10_134924_move_settings.php | 3 +-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/app/Http/Controllers/DiagnosticsController.php b/app/Http/Controllers/DiagnosticsController.php index 28dfaffb0cb..5868f7c9e5e 100644 --- a/app/Http/Controllers/DiagnosticsController.php +++ b/app/Http/Controllers/DiagnosticsController.php @@ -249,8 +249,10 @@ public function get_config() // Load settings $settings = $this->configFunctions->min_info(); foreach ($settings as $key => $value) { - if (!is_array($value)) { + if (!is_array($value) && !is_null($value)) { $configs[] = $this->line($key . ':', $value); + } elseif (is_null($value)) { + $configs[] = 'Error: ' . $key . ' has a NULL value!'; } } } catch (QueryException $e) { diff --git a/database/migrations/2018_08_10_134924_move_settings.php b/database/migrations/2018_08_10_134924_move_settings.php index fd5c139fc39..dffd16c4c7c 100644 --- a/database/migrations/2018_08_10_134924_move_settings.php +++ b/database/migrations/2018_08_10_134924_move_settings.php @@ -58,8 +58,7 @@ public function up() Configs::where('key', '=', $result->key . '_col')->update(['value' => $order_by[2] ?? 'id']); Configs::where('key', '=', $result->key . '_order')->update(['value' => $order_by[3] ?? 'DESC']); } elseif (!in_array($result->key, ['checkForUpdates', 'hide_version_number', 'identifier', 'php_script_limit', 'plugins', 'public_search', 'useExiftool', 'version'])) { - Configs::where('key', '=', $result->key)->update(['value' => $result->value]); - Logs::notice(__FUNCTION__, __LINE__, env('DB_OLD_LYCHEE_PREFIX', '') . 'lychee_settings does not exist!'); + Configs::where('key', '=', $result->key)->update(['value' => $result->value ?? '']); } } } else { From ddfd4a953d1737a5dd881b5e333e73a2a9ec6914 Mon Sep 17 00:00:00 2001 From: ildyria Date: Tue, 1 Sep 2020 10:15:07 +0200 Subject: [PATCH 2/2] add tests coverage --- tests/Feature/DiagnosticsTest.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tests/Feature/DiagnosticsTest.php b/tests/Feature/DiagnosticsTest.php index 9d0a8180bba..72d85646881 100644 --- a/tests/Feature/DiagnosticsTest.php +++ b/tests/Feature/DiagnosticsTest.php @@ -4,6 +4,7 @@ namespace Tests\Feature; +use App\Configs; use Tests\Feature\Lib\SessionUnitTest; use Tests\TestCase; @@ -25,12 +26,16 @@ public function test_diagnostics() $response = $this->get('/Diagnostics'); $response->assertStatus(200); // code 200 something + Configs::where('key', '=', 'lossless_optimization')->update(['value' => null]); + $response = $this->post('/api/Diagnostics'); $response->assertStatus(200); // code 200 something too $response = $this->post('/api/Diagnostics::getSize'); $response->assertStatus(200); // code 200 something too + Configs::where('key', '=', 'lossless_optimization')->update(['value' => '1']); + $session_tests->logout($this); } }