Skip to content

Commit abd2a42

Browse files
committed
Fix data integrity exception thrown when attempting to store updated server egg variables
1 parent 08a112f commit abd2a42

File tree

3 files changed

+10
-5
lines changed

3 files changed

+10
-5
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ This project follows [Semantic Versioning](http://semver.org) guidelines.
1010
* Fixes improper behavior when marking an egg as copying the configuration from another.
1111
* 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.
1212
* Added validation to port allocations to prevent allocation of restricted or invalid ports.
13+
* Fix data integrity exception thrown when attempting to store updated server egg variables.
1314

1415
### Changed
1516
* Panel now throws proper 504: Gateway Timeout errors on server listing when daemon is offline.

app/Services/Servers/StartupModificationService.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ public function handle(Server $server, array $data): Server
105105
'server_id' => $server->id,
106106
'variable_id' => $result->id,
107107
], [
108-
'variable_value' => $result->value,
108+
'variable_value' => $result->value ?? '',
109109
]);
110110
});
111111
}

tests/Unit/Services/Servers/StartupModificationServiceTest.php

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -121,14 +121,18 @@ public function testStartupModificationAsAdminUser()
121121
$this->connection->shouldReceive('beginTransaction')->withNoArgs()->once()->andReturnNull();
122122
$this->validatorService->shouldReceive('setUserLevel')->with(User::USER_LEVEL_ADMIN)->once()->andReturnNull();
123123
$this->validatorService->shouldReceive('handle')->with(456, ['test' => 'abcd1234'])->once()->andReturn(
124-
collect([(object) ['id' => 1, 'value' => 'stored-value']])
124+
collect([(object) ['id' => 1, 'value' => 'stored-value'], (object) ['id' => 2, 'value' => null]])
125125
);
126126

127-
$this->serverVariableRepository->shouldReceive('withoutFreshModel')->withNoArgs()->once()->andReturnSelf();
128-
$this->serverVariableRepository->shouldReceive('updateOrCreate')->with([
127+
$this->serverVariableRepository->shouldReceive('withoutFreshModel->updateOrCreate')->once()->with([
129128
'server_id' => $model->id,
130129
'variable_id' => 1,
131-
], ['variable_value' => 'stored-value'])->once()->andReturnNull();
130+
], ['variable_value' => 'stored-value'])->andReturnNull();
131+
132+
$this->serverVariableRepository->shouldReceive('withoutFreshModel->updateOrCreate')->once()->with([
133+
'server_id' => $model->id,
134+
'variable_id' => 2,
135+
], ['variable_value' => ''])->andReturnNull();
132136

133137
$this->eggRepository->shouldReceive('setColumns->find')->once()->with($eggModel->id)->andReturn($eggModel);
134138

0 commit comments

Comments
 (0)