Skip to content

Commit 4b9f025

Browse files
committed
Fix exception when trying to edit a host, ref pterodactyl#957
1 parent 541b9ec commit 4b9f025

File tree

3 files changed

+14
-8
lines changed

3 files changed

+14
-8
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ This project follows [Semantic Versioning](http://semver.org) guidelines.
88
* Fixes an exception when no token is entered on the 2-Factor enable/disable page and the form is submitted.
99
* Fixes an exception when trying to perform actions aganist a User model due to a validator that could not be cast to a string correctly.
1010
* Allow FQDNs in database host creation UI correctly.
11+
* Fixes database naming scheme using `d###_` rather than `s###_` when creating server databases.
12+
* Fix exception thrown when attempting to update an existing database host.
1113

1214
## v0.7.0 (Derelict Dermodactylus)
1315
### Fixed

app/Http/Controllers/Admin/DatabaseController.php

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
use PDOException;
1313
use Illuminate\View\View;
14+
use Pterodactyl\Models\DatabaseHost;
1415
use Illuminate\Http\RedirectResponse;
1516
use Prologue\Alerts\AlertsMessageBag;
1617
use Pterodactyl\Http\Controllers\Controller;
@@ -136,22 +137,25 @@ public function create(DatabaseHostFormRequest $request): RedirectResponse
136137
* Handle updating database host.
137138
*
138139
* @param \Pterodactyl\Http\Requests\Admin\DatabaseHostFormRequest $request
139-
* @param int $host
140+
* @param \Pterodactyl\Models\DatabaseHost $host
140141
* @return \Illuminate\Http\RedirectResponse
141142
*
142143
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
143144
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
144145
*/
145-
public function update(DatabaseHostFormRequest $request, int $host): RedirectResponse
146+
public function update(DatabaseHostFormRequest $request, DatabaseHost $host): RedirectResponse
146147
{
148+
$redirect = redirect()->route('admin.databases.view', $host->id);
149+
147150
try {
148-
$host = $this->updateService->handle($host, $request->normalize());
151+
$this->updateService->handle($host->id, $request->normalize());
149152
$this->alert->success('Database host was updated successfully.')->flash();
150153
} catch (PDOException $ex) {
151154
$this->alert->danger($ex->getMessage())->flash();
155+
$redirect->withInput($request->normalize());
152156
}
153157

154-
return redirect()->route('admin.databases.view', $host->id);
158+
return $redirect;
155159
}
156160

157161
/**

resources/themes/pterodactyl/admin/databases/view.blade.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,16 +29,16 @@
2929
<div class="box-body">
3030
<div class="form-group">
3131
<label for="pName" class="form-label">Name</label>
32-
<input type="text" id="pName" name="name" class="form-control" value="{{ $host->name }}" />
32+
<input type="text" id="pName" name="name" class="form-control" value="{{ old('name', $host->name) }}" />
3333
</div>
3434
<div class="form-group">
3535
<label for="pHost" class="form-label">Host</label>
36-
<input type="text" id="pHost" name="host" class="form-control" value="{{ $host->host }}" />
36+
<input type="text" id="pHost" name="host" class="form-control" value="{{ old('host', $host->host) }}" />
3737
<p class="text-muted small">The IP address or FQDN that should be used when attempting to connect to this MySQL host <em>from the panel</em> to add new databases.</p>
3838
</div>
3939
<div class="form-group">
4040
<label for="pPort" class="form-label">Port</label>
41-
<input type="text" id="pPort" name="port" class="form-control" value="{{ $host->port }}" />
41+
<input type="text" id="pPort" name="port" class="form-control" value="{{ old('port', $host->port) }}" />
4242
<p class="text-muted small">The port that MySQL is running on for this host.</p>
4343
</div>
4444
<div class="form-group">
@@ -66,7 +66,7 @@
6666
<div class="box-body">
6767
<div class="form-group">
6868
<label for="pUsername" class="form-label">Username</label>
69-
<input type="text" name="username" id="pUsername" class="form-control" value="{{ $host->username }}" />
69+
<input type="text" name="username" id="pUsername" class="form-control" value="{{ old('username', $host->username) }}" />
7070
<p class="text-muted small">The username of an account that has enough permissions to create new users and databases on the system.</p>
7171
</div>
7272
<div class="form-group">

0 commit comments

Comments
 (0)