This commit is contained in:
Dane Everitt 2017-12-30 19:56:42 -06:00
parent 1eaf1e3571
commit 10e2e6e379
No known key found for this signature in database
GPG key ID: EEA66103B3D71F53
5 changed files with 45 additions and 31 deletions

View file

@ -3,6 +3,11 @@ This file is a running track of new features and fixes to each version of the pa
This project follows [Semantic Versioning](http://semver.org) guidelines. This project follows [Semantic Versioning](http://semver.org) guidelines.
## v0.7.0-beta.4 (Derelict Dermodactylus)
### Fixed
* `[beta.3]` — Fixes a bug with the default environment file that was causing an inability to perform a fresh install when running package discovery.
* `[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.
## v0.7.0-beta.3 (Derelict Dermodactylus) ## v0.7.0-beta.3 (Derelict Dermodactylus)
### Fixed ### Fixed
* `[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. * `[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.

View file

@ -1,11 +1,4 @@
<?php <?php
/**
* Pterodactyl - Panel
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>.
*
* This software is licensed under the terms of the MIT license.
* https://opensource.org/licenses/MIT
*/
namespace Pterodactyl\Services\Eggs\Variables; namespace Pterodactyl\Services\Eggs\Variables;
@ -49,7 +42,7 @@ class VariableCreationService
)); ));
} }
$options = array_get($data, 'options', []); $options = array_get($data, 'options') ?? [];
return $this->repository->create(array_merge($data, [ return $this->repository->create(array_merge($data, [
'egg_id' => $egg, 'egg_id' => $egg,

View file

@ -1,11 +1,4 @@
<?php <?php
/**
* Pterodactyl - Panel
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>.
*
* This software is licensed under the terms of the MIT license.
* https://opensource.org/licenses/MIT
*/
namespace Pterodactyl\Services\Eggs\Variables; namespace Pterodactyl\Services\Eggs\Variables;
@ -69,7 +62,7 @@ class VariableUpdateService
} }
} }
$options = array_get($data, 'options', []); $options = array_get($data, 'options') ?? [];
return $this->repository->withoutFresh()->update($variable->id, array_merge($data, [ return $this->repository->withoutFresh()->update($variable->id, array_merge($data, [
'user_viewable' => in_array('user_viewable', $options), 'user_viewable' => in_array('user_viewable', $options),

View file

@ -1,17 +1,9 @@
<?php <?php
/**
* Pterodactyl - Panel
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>.
*
* This software is licensed under the terms of the MIT license.
* https://opensource.org/licenses/MIT
*/
namespace Tests\Unit\Services\Eggs\Variables; namespace Tests\Unit\Services\Eggs\Variables;
use Mockery as m; use Mockery as m;
use Tests\TestCase; use Tests\TestCase;
use Pterodactyl\Models\Egg;
use Pterodactyl\Models\EggVariable; use Pterodactyl\Models\EggVariable;
use Pterodactyl\Services\Eggs\Variables\VariableCreationService; use Pterodactyl\Services\Eggs\Variables\VariableCreationService;
use Pterodactyl\Contracts\Repository\EggVariableRepositoryInterface; use Pterodactyl\Contracts\Repository\EggVariableRepositoryInterface;
@ -73,6 +65,26 @@ class VariableCreationServiceTest extends TestCase
$this->assertInstanceOf(EggVariable::class, $this->service->handle(1, $data)); $this->assertInstanceOf(EggVariable::class, $this->service->handle(1, $data));
} }
/**
* Test that an empty (null) value passed in the option key is handled
* properly as an array.
*
* @see https://github.com/Pterodactyl/Panel/issues/841
*/
public function testNullOptionValueIsPassedAsArray()
{
$data = ['env_variable' => 'TEST_VAR_123', 'options' => null];
$this->repository->shouldReceive('create')->with([
'egg_id' => 1,
'user_viewable' => false,
'user_editable' => false,
'env_variable' => 'TEST_VAR_123',
'options' => null,
])->once()->andReturn(new EggVariable);
$this->assertInstanceOf(EggVariable::class, $this->service->handle(1, $data));
}
/** /**
* Test that all of the reserved variables defined in the model trigger an exception. * Test that all of the reserved variables defined in the model trigger an exception.
* *

View file

@ -1,11 +1,4 @@
<?php <?php
/**
* Pterodactyl - Panel
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>.
*
* This software is licensed under the terms of the MIT license.
* https://opensource.org/licenses/MIT
*/
namespace Tests\Unit\Services\Eggs\Variables; namespace Tests\Unit\Services\Eggs\Variables;
@ -100,6 +93,24 @@ class VariableUpdateServiceTest extends TestCase
$this->assertTrue($this->service->handle($this->model, ['env_variable' => 'TEST_VAR_123'])); $this->assertTrue($this->service->handle($this->model, ['env_variable' => 'TEST_VAR_123']));
} }
/**
* Test that an empty (null) value passed in the option key is handled
* properly as an array.
*
* @see https://github.com/Pterodactyl/Panel/issues/841
*/
public function testNullOptionValueIsPassedAsArray()
{
$this->repository->shouldReceive('withoutFresh')->withNoArgs()->once()->andReturnSelf()
->shouldReceive('update')->with($this->model->id, [
'user_viewable' => false,
'user_editable' => false,
'options' => null,
])->once()->andReturn(true);
$this->assertTrue($this->service->handle($this->model, ['options' => null]));
}
/** /**
* Test that data passed into the handler is overwritten inside the handler. * Test that data passed into the handler is overwritten inside the handler.
*/ */