From 066ed5cddad1f12909c6dfa5c0f05120ec1e364f Mon Sep 17 00:00:00 2001 From: Dane Everitt Date: Tue, 23 Jun 2020 20:26:48 -0700 Subject: [PATCH] Don't prevent deletion if a DB host is unreachable and it is a force delete; closes #2085 --- app/Services/Servers/ServerDeletionService.php | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/app/Services/Servers/ServerDeletionService.php b/app/Services/Servers/ServerDeletionService.php index d4ce9a896..8d7217769 100644 --- a/app/Services/Servers/ServerDeletionService.php +++ b/app/Services/Servers/ServerDeletionService.php @@ -2,6 +2,7 @@ namespace Pterodactyl\Services\Servers; +use Exception; use Psr\Log\LoggerInterface; use Pterodactyl\Models\Server; use Illuminate\Database\ConnectionInterface; @@ -109,7 +110,15 @@ class ServerDeletionService $this->connection->transaction(function () use ($server) { $this->databaseRepository->setColumns('id')->findWhere([['server_id', '=', $server->id]])->each(function ($item) { - $this->databaseManagementService->delete($item->id); + try { + $this->databaseManagementService->delete($item->id); + } catch (Exception $exception) { + if ($this->force) { + $this->writer->warning($exception); + } else { + throw $exception; + } + } }); $this->repository->delete($server->id);