Skip to content

Commit 3bb9bf0

Browse files
committed
Pass the updated model through for updating node config, rather than old model, ref pterodactyl#1237
1 parent 7ed9c7c commit 3bb9bf0

File tree

3 files changed

+5
-11
lines changed

3 files changed

+5
-11
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ This project follows [Semantic Versioning](http://semver.org) guidelines.
77
### Fixed
88
* Scheduled tasks triggered manually no longer improperly change the `next_run_at` time and do not run twice in a row anymore.
99
* Changing the maximum web-based file upload size for a node now properly validates and updates.
10+
* Changing configuration values for a node now correctly updates them on the daemon on the first request, rather than requiring a second request to set them.
1011

1112
### Changed
1213
* Egg and server variable values are no longer limited to 191 characters. Turns out some games require a large number of characters in these fields.

app/Http/Controllers/Api/Application/Nodes/NodeController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ public function store(StoreNodeRequest $request): JsonResponse
124124
*/
125125
public function update(UpdateNodeRequest $request): array
126126
{
127-
$node = $this->updateService->returnUpdatedModel()->handle(
127+
$node = $this->updateService->handle(
128128
$request->getModel(Node::class), $request->validated()
129129
);
130130

app/Services/Nodes/NodeUpdateService.php

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,13 @@
1313
use GuzzleHttp\Exception\ConnectException;
1414
use GuzzleHttp\Exception\RequestException;
1515
use Illuminate\Database\ConnectionInterface;
16-
use Pterodactyl\Traits\Services\ReturnsUpdatedModels;
1716
use Pterodactyl\Contracts\Repository\NodeRepositoryInterface;
1817
use Pterodactyl\Exceptions\Http\Connection\DaemonConnectionException;
1918
use Pterodactyl\Exceptions\Service\Node\ConfigurationNotPersistedException;
2019
use Pterodactyl\Contracts\Repository\Daemon\ConfigurationRepositoryInterface;
2120

2221
class NodeUpdateService
2322
{
24-
use ReturnsUpdatedModels;
25-
2623
/**
2724
* @var \Illuminate\Database\ConnectionInterface
2825
*/
@@ -74,14 +71,10 @@ public function handle(Node $node, array $data)
7471
}
7572

7673
$this->connection->beginTransaction();
77-
if ($this->getUpdatedModel()) {
78-
$response = $this->repository->update($node->id, $data);
79-
} else {
80-
$response = $this->repository->withoutFreshModel()->update($node->id, $data);
81-
}
74+
$updatedModel = $this->repository->update($node->id, $data);
8275

8376
try {
84-
$this->configRepository->setNode($node)->update();
77+
$this->configRepository->setNode($updatedModel)->update();
8578
$this->connection->commit();
8679
} catch (RequestException $exception) {
8780
// Failed to connect to the Daemon. Let's go ahead and save the configuration
@@ -95,6 +88,6 @@ public function handle(Node $node, array $data)
9588
throw new DaemonConnectionException($exception);
9689
}
9790

98-
return $response;
91+
return $updatedModel;
9992
}
10093
}

0 commit comments

Comments
 (0)