Skip to content

Commit ffc8d48

Browse files
committed
Fix unability to store '-1' in the database properly
1 parent 958c29c commit ffc8d48

File tree

3 files changed

+40
-12
lines changed

3 files changed

+40
-12
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ This project follows [Semantic Versioning](http://semver.org) guidelines.
1010
* `[beta.3]` — Fixes a bug that would cause an error when attempting to create a new user on the Panel.
1111
* `[beta.3]` — Fixes error handling of the settings service provider when no migrations have been run.
1212
* `[beta.3]` — Fixes validation error when trying to use 'None' as the 'Copy Script From' option for an egg script.
13+
* Fixes a design bug in the database that prevented the storage of negative numbers, thus preventing a server from being assigned unlimited swap.
14+
1315
### Added
1416
* Nest and Egg listings now show the associated ID in order to make API requests easier.
1517

app/Services/Servers/BuildModificationService.php

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,4 @@
11
<?php
2-
/**
3-
* Pterodactyl - Panel
4-
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>.
5-
*
6-
* This software is licensed under the terms of the MIT license.
7-
* https://opensource.org/licenses/MIT
8-
*/
92

103
namespace Pterodactyl\Services\Servers;
114

@@ -113,6 +106,7 @@ public function getBuild($attribute = null)
113106
*
114107
* @throws \Pterodactyl\Exceptions\DisplayException
115108
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
109+
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
116110
*/
117111
public function handle($server, array $data)
118112
{
@@ -138,11 +132,11 @@ public function handle($server, array $data)
138132
}
139133

140134
$server = $this->repository->update($server->id, [
141-
'memory' => array_get($data, 'memory', $server->memory),
142-
'swap' => array_get($data, 'swap', $server->swap),
143-
'io' => array_get($data, 'io', $server->io),
144-
'cpu' => array_get($data, 'cpu', $server->cpu),
145-
'disk' => array_get($data, 'disk', $server->disk),
135+
'memory' => (int) array_get($data, 'memory', $server->memory),
136+
'swap' => (int) array_get($data, 'swap', $server->swap),
137+
'io' => (int) array_get($data, 'io', $server->io),
138+
'cpu' => (int) array_get($data, 'cpu', $server->cpu),
139+
'disk' => (int) array_get($data, 'disk', $server->disk),
146140
'allocation_id' => array_get($data, 'allocation_id', $server->allocation_id),
147141
]);
148142

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?php
2+
3+
use Illuminate\Support\Facades\Schema;
4+
use Illuminate\Database\Schema\Blueprint;
5+
use Illuminate\Database\Migrations\Migration;
6+
7+
class AllowNegativeValuesForServerSwap extends Migration
8+
{
9+
/**
10+
* Run the migrations.
11+
*
12+
* @return void
13+
*/
14+
public function up()
15+
{
16+
Schema::table('servers', function (Blueprint $table) {
17+
$table->integer('swap')->change();
18+
});
19+
}
20+
21+
/**
22+
* Reverse the migrations.
23+
*
24+
* @return void
25+
*/
26+
public function down()
27+
{
28+
Schema::table('servers', function (Blueprint $table) {
29+
$table->unsignedInteger('swap')->change();
30+
});
31+
}
32+
}

0 commit comments

Comments
 (0)