Skip to content

Commit d9355b9

Browse files
committed
Fix exception when adjusting mail settings, closes pterodactyl#907
1 parent 48c933f commit d9355b9

File tree

4 files changed

+14
-12
lines changed

4 files changed

+14
-12
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ This project follows [Semantic Versioning](http://semver.org) guidelines.
77
### Fixed
88
* `[rc.1]` — Fixes exception thrown when revoking user sessions.
99
* `[rc.1]` — Fixes exception that would occur when trying to delete allocations from a node.
10+
* `[rc.1]` — Fixes exception thown when attempting to adjust mail settings as well as a validation error thrown afterwards.
1011

1112
## v0.7.0-rc.1 (Derelict Dermodactylus)
1213
### Fixed

app/Contracts/Repository/SettingsRepositoryInterface.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@ interface SettingsRepositoryInterface extends RepositoryInterface
77
/**
88
* Store a new persistent setting in the database.
99
*
10-
* @param string $key
11-
* @param string $value
10+
* @param string $key
11+
* @param string|null $value
1212
*
1313
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
1414
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
1515
*/
16-
public function set(string $key, string $value);
16+
public function set(string $key, string $value = null);
1717

1818
/**
1919
* Retrieve a persistent setting from the database.

app/Http/Requests/Admin/Settings/MailSettingsFormRequest.php

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace Pterodactyl\Http\Requests\Admin\Settings;
44

5+
use Illuminate\Validation\Rule;
56
use Pterodactyl\Http\Requests\Admin\AdminFormRequest;
67

78
class MailSettingsFormRequest extends AdminFormRequest
@@ -16,11 +17,11 @@ public function rules()
1617
return [
1718
'mail:host' => 'required|string',
1819
'mail:port' => 'required|integer|between:1,65535',
19-
'mail:encryption' => 'present|string|in:"",tls,ssl',
20-
'mail:username' => 'string|max:255',
21-
'mail:password' => 'string|max:255',
20+
'mail:encryption' => ['present', Rule::in([null, 'tls', 'ssl'])],
21+
'mail:username' => 'nullable|string|max:255',
22+
'mail:password' => 'nullable|string|max:255',
2223
'mail:from:address' => 'required|string|email',
23-
'mail:from:name' => 'string|max:255',
24+
'mail:from:name' => 'nullable|string|max:255',
2425
];
2526
}
2627

@@ -31,7 +32,7 @@ public function rules()
3132
* @param array $only
3233
* @return array
3334
*/
34-
public function normalize($only = [])
35+
public function normalize(array $only = null)
3536
{
3637
$keys = array_flip(array_keys($this->rules()));
3738

app/Repositories/Eloquent/SettingsRepository.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,17 +30,17 @@ public function model()
3030
/**
3131
* Store a new persistent setting in the database.
3232
*
33-
* @param string $key
34-
* @param string $value
33+
* @param string $key
34+
* @param string|null $value
3535
*
3636
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
3737
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
3838
*/
39-
public function set(string $key, string $value)
39+
public function set(string $key, string $value = null)
4040
{
4141
// Clear item from the cache.
4242
$this->clearCache($key);
43-
$this->withoutFreshModel()->updateOrCreate(['key' => $key], ['value' => $value]);
43+
$this->withoutFreshModel()->updateOrCreate(['key' => $key], ['value' => $value ?? '']);
4444

4545
self::$cache[$key] = $value;
4646
}

0 commit comments

Comments
 (0)