Skip to content

Commit 958c29c

Browse files
committed
Fix empty server descriptions throwing SQL errors, closes pterodactyl#842
1 parent 4457634 commit 958c29c

File tree

3 files changed

+6
-5
lines changed

3 files changed

+6
-5
lines changed

app/Models/Server.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ class Server extends Model implements CleansAttributes, ValidableContract
7676
'owner_id' => 'exists:users,id',
7777
'name' => 'regex:/^([\w .-]{1,200})$/',
7878
'node_id' => 'exists:nodes,id',
79-
'description' => 'nullable|string',
79+
'description' => 'string',
8080
'memory' => 'numeric|min:0',
8181
'swap' => 'numeric|min:-1',
8282
'io' => 'numeric|between:10,1000',

app/Services/Servers/DetailsModificationService.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,9 +95,9 @@ public function edit($server, array $data)
9595

9696
$this->connection->beginTransaction();
9797
$this->repository->withoutFresh()->update($server->id, [
98-
'owner_id' => array_get($data, 'owner_id') ?? $server->owner_id,
99-
'name' => array_get($data, 'name') ?? $server->name,
100-
'description' => array_get($data, 'description') ?? $server->description,
98+
'owner_id' => array_get($data, 'owner_id'),
99+
'name' => array_get($data, 'name'),
100+
'description' => array_get($data, 'description', ''),
101101
], true, true);
102102

103103
if (array_get($data, 'owner_id') != $server->owner_id) {

app/Services/Servers/ServerCreationService.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ public function __construct(
106106
* @throws \Pterodactyl\Exceptions\DisplayException
107107
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
108108
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
109+
* @throws \Illuminate\Validation\ValidationException
109110
*/
110111
public function create(array $data)
111112
{
@@ -117,7 +118,7 @@ public function create(array $data)
117118
'uuidShort' => str_random(8),
118119
'node_id' => array_get($data, 'node_id'),
119120
'name' => array_get($data, 'name'),
120-
'description' => array_get($data, 'description'),
121+
'description' => array_get($data, 'description', ''),
121122
'skip_scripts' => isset($data['skip_scripts']),
122123
'suspended' => false,
123124
'owner_id' => array_get($data, 'owner_id'),

0 commit comments

Comments
 (0)