Skip to content

Commit 8771597

Browse files
DaneEverittMinerPL
andcommitted
Fix database deletion; closes pterodactyl#4114
Co-Authored-By: Dawid <minerpl03@gmail.com>
1 parent c0a3dea commit 8771597

File tree

2 files changed

+11
-19
lines changed

2 files changed

+11
-19
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@ This file is a running track of new features and fixes to each version of the pa
33

44
This project follows [Semantic Versioning](http://semver.org) guidelines.
55

6+
## v1.8.2
7+
### Fixed
8+
* Fixes a bug causing a 404 error when attempting to delete a database from a server in the admin control panel.
9+
* Fixes console input auto-capitalizing and auto-correcting when entering text on some mobile devices.
10+
611
## v1.8.1
712
### Fixed
813
* Fixes a bug causing mounts to return a 404 error when adding them to a server.

app/Http/Controllers/Admin/ServersController.php

Lines changed: 6 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
use Pterodactyl\Models\User;
1414
use Pterodactyl\Models\Mount;
1515
use Pterodactyl\Models\Server;
16+
use Pterodactyl\Models\Database;
1617
use Pterodactyl\Models\MountServer;
1718
use Prologue\Alerts\AlertsMessageBag;
1819
use Pterodactyl\Exceptions\DisplayException;
@@ -344,18 +345,13 @@ public function newDatabase(StoreServerDatabaseRequest $request, Server $server)
344345
/**
345346
* Resets the database password for a specific database on this server.
346347
*
347-
* @param int $server
348-
*
349-
* @return \Illuminate\Http\RedirectResponse
348+
* @return \Illuminate\Http\Response
350349
*
351350
* @throws \Throwable
352351
*/
353-
public function resetDatabasePassword(Request $request, $server)
352+
public function resetDatabasePassword(Request $request, Server $server)
354353
{
355-
$database = $this->databaseRepository->findFirstWhere([
356-
['server_id', '=', $server],
357-
['id', '=', $request->input('database')],
358-
]);
354+
$database = $server->databases()->where('id', $request->input('database'))->findOrFail();
359355

360356
$this->databasePasswordService->handle($database);
361357

@@ -365,21 +361,12 @@ public function resetDatabasePassword(Request $request, $server)
365361
/**
366362
* Deletes a database from a server.
367363
*
368-
* @param int $server
369-
* @param int $database
370-
*
371-
* @return \Illuminate\Http\RedirectResponse
364+
* @return \Illuminate\Http\Response
372365
*
373366
* @throws \Exception
374-
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
375367
*/
376-
public function deleteDatabase($server, $database)
368+
public function deleteDatabase(Server $server, Database $database)
377369
{
378-
$database = $this->databaseRepository->findFirstWhere([
379-
['server_id', '=', $server],
380-
['id', '=', $database],
381-
]);
382-
383370
$this->databaseManagementService->delete($database);
384371

385372
return response('', 204);

0 commit comments

Comments
 (0)