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 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.
* 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)
### Fixed

View file

@ -11,6 +11,7 @@ namespace Pterodactyl\Http\Controllers\Admin;
use PDOException;
use Illuminate\View\View;
use Pterodactyl\Models\DatabaseHost;
use Illuminate\Http\RedirectResponse;
use Prologue\Alerts\AlertsMessageBag;
use Pterodactyl\Http\Controllers\Controller;
@ -136,22 +137,25 @@ class DatabaseController extends Controller
* Handle updating database host.
*
* @param \Pterodactyl\Http\Requests\Admin\DatabaseHostFormRequest $request
* @param int $host
* @param \Pterodactyl\Models\DatabaseHost $host
* @return \Illuminate\Http\RedirectResponse
*
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
* @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 {
$host = $this->updateService->handle($host, $request->normalize());
$this->updateService->handle($host->id, $request->normalize());
$this->alert->success('Database host was updated successfully.')->flash();
} catch (PDOException $ex) {
$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="form-group">
<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 class="form-group">
<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>
</div>
<div class="form-group">
<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>
</div>
<div class="form-group">
@ -66,7 +66,7 @@
<div class="box-body">
<div class="form-group">
<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>
</div>
<div class="form-group">