diff --git a/CHANGELOG.md b/CHANGELOG.md index 75cb796c6..77cad6222 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ This project follows [Semantic Versioning](http://semver.org) guidelines. * Fixes improper behavior when marking an egg as copying the configuration from another. * Debug bar is only checked when the app is set to debug mode in the API session handler, rather than when it is in local mode to match the plugin settings. * Added validation to port allocations to prevent allocation of restricted or invalid ports. +* Fix data integrity exception thrown when attempting to store updated server egg variables. ### Changed * Panel now throws proper 504: Gateway Timeout errors on server listing when daemon is offline. diff --git a/app/Services/Servers/StartupModificationService.php b/app/Services/Servers/StartupModificationService.php index 4e954ae1f..9fa1390db 100644 --- a/app/Services/Servers/StartupModificationService.php +++ b/app/Services/Servers/StartupModificationService.php @@ -105,7 +105,7 @@ class StartupModificationService 'server_id' => $server->id, 'variable_id' => $result->id, ], [ - 'variable_value' => $result->value, + 'variable_value' => $result->value ?? '', ]); }); } diff --git a/tests/Unit/Services/Servers/StartupModificationServiceTest.php b/tests/Unit/Services/Servers/StartupModificationServiceTest.php index 99453e515..5b6046753 100644 --- a/tests/Unit/Services/Servers/StartupModificationServiceTest.php +++ b/tests/Unit/Services/Servers/StartupModificationServiceTest.php @@ -121,14 +121,18 @@ class StartupModificationServiceTest extends TestCase $this->connection->shouldReceive('beginTransaction')->withNoArgs()->once()->andReturnNull(); $this->validatorService->shouldReceive('setUserLevel')->with(User::USER_LEVEL_ADMIN)->once()->andReturnNull(); $this->validatorService->shouldReceive('handle')->with(456, ['test' => 'abcd1234'])->once()->andReturn( - collect([(object) ['id' => 1, 'value' => 'stored-value']]) + collect([(object) ['id' => 1, 'value' => 'stored-value'], (object) ['id' => 2, 'value' => null]]) ); - $this->serverVariableRepository->shouldReceive('withoutFreshModel')->withNoArgs()->once()->andReturnSelf(); - $this->serverVariableRepository->shouldReceive('updateOrCreate')->with([ + $this->serverVariableRepository->shouldReceive('withoutFreshModel->updateOrCreate')->once()->with([ 'server_id' => $model->id, 'variable_id' => 1, - ], ['variable_value' => 'stored-value'])->once()->andReturnNull(); + ], ['variable_value' => 'stored-value'])->andReturnNull(); + + $this->serverVariableRepository->shouldReceive('withoutFreshModel->updateOrCreate')->once()->with([ + 'server_id' => $model->id, + 'variable_id' => 2, + ], ['variable_value' => ''])->andReturnNull(); $this->eggRepository->shouldReceive('setColumns->find')->once()->with($eggModel->id)->andReturn($eggModel);