Skip to content

Commit 10e2e6e

Browse files
committed
1 parent 1eaf1e3 commit 10e2e6e

File tree

5 files changed

+45
-31
lines changed

5 files changed

+45
-31
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+
## v0.7.0-beta.4 (Derelict Dermodactylus)
7+
### Fixed
8+
* `[beta.3]` — Fixes a bug with the default environment file that was causing an inability to perform a fresh install when running package discovery.
9+
* `[beta.3]` — Fixes an edge case caused by the Laravel 5.5 upgrade that would try to perform an in_array check aganist a null value.
10+
611
## v0.7.0-beta.3 (Derelict Dermodactylus)
712
### Fixed
813
* `[beta.2]` — Fixes a bug that would cause an endless exception message stream in the console when attemping to setup environment settings in certain instances.

app/Services/Eggs/Variables/VariableCreationService.php

Lines changed: 1 addition & 8 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\Eggs\Variables;
114

@@ -49,7 +42,7 @@ public function handle(int $egg, array $data): EggVariable
4942
));
5043
}
5144

52-
$options = array_get($data, 'options', []);
45+
$options = array_get($data, 'options') ?? [];
5346

5447
return $this->repository->create(array_merge($data, [
5548
'egg_id' => $egg,

app/Services/Eggs/Variables/VariableUpdateService.php

Lines changed: 1 addition & 8 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\Eggs\Variables;
114

@@ -69,7 +62,7 @@ public function handle($variable, array $data)
6962
}
7063
}
7164

72-
$options = array_get($data, 'options', []);
65+
$options = array_get($data, 'options') ?? [];
7366

7467
return $this->repository->withoutFresh()->update($variable->id, array_merge($data, [
7568
'user_viewable' => in_array('user_viewable', $options),

tests/Unit/Services/Eggs/Variables/VariableCreationServiceTest.php

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,9 @@
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 Tests\Unit\Services\Eggs\Variables;
114

125
use Mockery as m;
136
use Tests\TestCase;
14-
use Pterodactyl\Models\Egg;
157
use Pterodactyl\Models\EggVariable;
168
use Pterodactyl\Services\Eggs\Variables\VariableCreationService;
179
use Pterodactyl\Contracts\Repository\EggVariableRepositoryInterface;
@@ -73,6 +65,26 @@ public function testOptionsPassedInArrayKeyAreParsedProperly()
7365
$this->assertInstanceOf(EggVariable::class, $this->service->handle(1, $data));
7466
}
7567

68+
/**
69+
* Test that an empty (null) value passed in the option key is handled
70+
* properly as an array.
71+
*
72+
* @see https://github.com/Pterodactyl/Panel/issues/841
73+
*/
74+
public function testNullOptionValueIsPassedAsArray()
75+
{
76+
$data = ['env_variable' => 'TEST_VAR_123', 'options' => null];
77+
$this->repository->shouldReceive('create')->with([
78+
'egg_id' => 1,
79+
'user_viewable' => false,
80+
'user_editable' => false,
81+
'env_variable' => 'TEST_VAR_123',
82+
'options' => null,
83+
])->once()->andReturn(new EggVariable);
84+
85+
$this->assertInstanceOf(EggVariable::class, $this->service->handle(1, $data));
86+
}
87+
7688
/**
7789
* Test that all of the reserved variables defined in the model trigger an exception.
7890
*

tests/Unit/Services/Eggs/Variables/VariableUpdateServiceTest.php

Lines changed: 18 additions & 7 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 Tests\Unit\Services\Eggs\Variables;
114

@@ -100,6 +93,24 @@ public function testVariableIsUpdatedWhenValidEnvironmentVariableIsPassed()
10093
$this->assertTrue($this->service->handle($this->model, ['env_variable' => 'TEST_VAR_123']));
10194
}
10295

96+
/**
97+
* Test that an empty (null) value passed in the option key is handled
98+
* properly as an array.
99+
*
100+
* @see https://github.com/Pterodactyl/Panel/issues/841
101+
*/
102+
public function testNullOptionValueIsPassedAsArray()
103+
{
104+
$this->repository->shouldReceive('withoutFresh')->withNoArgs()->once()->andReturnSelf()
105+
->shouldReceive('update')->with($this->model->id, [
106+
'user_viewable' => false,
107+
'user_editable' => false,
108+
'options' => null,
109+
])->once()->andReturn(true);
110+
111+
$this->assertTrue($this->service->handle($this->model, ['options' => null]));
112+
}
113+
103114
/**
104115
* Test that data passed into the handler is overwritten inside the handler.
105116
*/

0 commit comments

Comments
 (0)