Skip to content

Commit

Permalink
fix LycheeOrg#708 - Add a few failsafe (LycheeOrg#709)
Browse files Browse the repository at this point in the history
* fix LycheeOrg#708 
* add tests coverage
  • Loading branch information
ildyria authored and Aleshus committed Sep 3, 2020
1 parent c1278f5 commit bb3c8e7
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
4 changes: 3 additions & 1 deletion app/Http/Controllers/DiagnosticsController.php
Expand Up @@ -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) {
Expand Down
3 changes: 1 addition & 2 deletions database/migrations/2018_08_10_134924_move_settings.php
Expand Up @@ -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 {
Expand Down
5 changes: 5 additions & 0 deletions tests/Feature/DiagnosticsTest.php
Expand Up @@ -4,6 +4,7 @@

namespace Tests\Feature;

use App\Configs;
use Tests\Feature\Lib\SessionUnitTest;
use Tests\TestCase;

Expand All @@ -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);
}
}

0 comments on commit bb3c8e7

Please sign in to comment.