Fix exception when trying to edit a host, ref #957

This commit is contained in:
Dane Everitt 2018-02-18 14:10:12 -06:00
parent 541b9ec7f5
commit 4b9f025e98
No known key found for this signature in database
GPG key ID: EEA66103B3D71F53
3 changed files with 14 additions and 8 deletions

View file

@ -8,6 +8,8 @@ This project follows [Semantic Versioning](http://semver.org) guidelines.
* Fixes an exception when no token is entered on the 2-Factor enable/disable page and the form is submitted. * Fixes an exception when no token is entered on the 2-Factor enable/disable page and the form is submitted.
* 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. * 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.
* Allow FQDNs in database host creation UI correctly. * Allow FQDNs in database host creation UI correctly.
* Fixes database naming scheme using `d###_` rather than `s###_` when creating server databases.
* Fix exception thrown when attempting to update an existing database host.
## v0.7.0 (Derelict Dermodactylus) ## v0.7.0 (Derelict Dermodactylus)
### Fixed ### Fixed

View file

@ -11,6 +11,7 @@ namespace Pterodactyl\Http\Controllers\Admin;
use PDOException; use PDOException;
use Illuminate\View\View; use Illuminate\View\View;
use Pterodactyl\Models\DatabaseHost;
use Illuminate\Http\RedirectResponse; use Illuminate\Http\RedirectResponse;
use Prologue\Alerts\AlertsMessageBag; use Prologue\Alerts\AlertsMessageBag;
use Pterodactyl\Http\Controllers\Controller; use Pterodactyl\Http\Controllers\Controller;
@ -136,22 +137,25 @@ class DatabaseController extends Controller
* Handle updating database host. * Handle updating database host.
* *
* @param \Pterodactyl\Http\Requests\Admin\DatabaseHostFormRequest $request * @param \Pterodactyl\Http\Requests\Admin\DatabaseHostFormRequest $request
* @param int $host * @param \Pterodactyl\Models\DatabaseHost $host
* @return \Illuminate\Http\RedirectResponse * @return \Illuminate\Http\RedirectResponse
* *
* @throws \Pterodactyl\Exceptions\Model\DataValidationException * @throws \Pterodactyl\Exceptions\Model\DataValidationException
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException * @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
*/ */
public function update(DatabaseHostFormRequest $request, int $host): RedirectResponse public function update(DatabaseHostFormRequest $request, DatabaseHost $host): RedirectResponse
{ {
$redirect = redirect()->route('admin.databases.view', $host->id);
try { try {
$host = $this->updateService->handle($host, $request->normalize()); $this->updateService->handle($host->id, $request->normalize());
$this->alert->success('Database host was updated successfully.')->flash(); $this->alert->success('Database host was updated successfully.')->flash();
} catch (PDOException $ex) { } catch (PDOException $ex) {
$this->alert->danger($ex->getMessage())->flash(); $this->alert->danger($ex->getMessage())->flash();
$redirect->withInput($request->normalize());
} }
return redirect()->route('admin.databases.view', $host->id); return $redirect;
} }
/** /**

View file

@ -29,16 +29,16 @@
<div class="box-body"> <div class="box-body">
<div class="form-group"> <div class="form-group">
<label for="pName" class="form-label">Name</label> <label for="pName" class="form-label">Name</label>
<input type="text" id="pName" name="name" class="form-control" value="{{ $host->name }}" /> <input type="text" id="pName" name="name" class="form-control" value="{{ old('name', $host->name) }}" />
</div> </div>
<div class="form-group"> <div class="form-group">
<label for="pHost" class="form-label">Host</label> <label for="pHost" class="form-label">Host</label>
<input type="text" id="pHost" name="host" class="form-control" value="{{ $host->host }}" /> <input type="text" id="pHost" name="host" class="form-control" value="{{ old('host', $host->host) }}" />
<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> <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>
</div> </div>
<div class="form-group"> <div class="form-group">
<label for="pPort" class="form-label">Port</label> <label for="pPort" class="form-label">Port</label>
<input type="text" id="pPort" name="port" class="form-control" value="{{ $host->port }}" /> <input type="text" id="pPort" name="port" class="form-control" value="{{ old('port', $host->port) }}" />
<p class="text-muted small">The port that MySQL is running on for this host.</p> <p class="text-muted small">The port that MySQL is running on for this host.</p>
</div> </div>
<div class="form-group"> <div class="form-group">
@ -66,7 +66,7 @@
<div class="box-body"> <div class="box-body">
<div class="form-group"> <div class="form-group">
<label for="pUsername" class="form-label">Username</label> <label for="pUsername" class="form-label">Username</label>
<input type="text" name="username" id="pUsername" class="form-control" value="{{ $host->username }}" /> <input type="text" name="username" id="pUsername" class="form-control" value="{{ old('username', $host->username) }}" />
<p class="text-muted small">The username of an account that has enough permissions to create new users and databases on the system.</p> <p class="text-muted small">The username of an account that has enough permissions to create new users and databases on the system.</p>
</div> </div>
<div class="form-group"> <div class="form-group">