fix: [diagnostics] allow for certain settings to be empty, fixes #176
- via the empty => true keypull/196/head
parent
cce4115418
commit
04b640c8b6
|
@ -163,18 +163,22 @@ class BaseSettingsProvider
|
||||||
$setting['error'] = false;
|
$setting['error'] = false;
|
||||||
if (!$skipValidation) {
|
if (!$skipValidation) {
|
||||||
$validationResult = true;
|
$validationResult = true;
|
||||||
if (!isset($setting['value'])) {
|
if (empty($setting['value']) && !empty($setting['empty'])) {
|
||||||
$validationResult = $this->settingValidator->testEmptyBecomesDefault(null, $setting);
|
$validationResult = true;
|
||||||
} else if (isset($setting['test'])) {
|
} else {
|
||||||
$setting['value'] = $setting['value'] ?? '';
|
if (!isset($setting['value'])) {
|
||||||
$validationResult = $this->evaluateFunctionForSetting($setting['test'], $setting);
|
$validationResult = $this->settingValidator->testEmptyBecomesDefault(null, $setting);
|
||||||
}
|
} else if (isset($setting['test'])) {
|
||||||
if ($validationResult !== true) {
|
$setting['value'] = $setting['value'] ?? '';
|
||||||
$setting['severity'] = $setting['severity'] ?? 'warning';
|
$validationResult = $this->evaluateFunctionForSetting($setting['test'], $setting);
|
||||||
if (!in_array($setting['severity'], $this->severities)) {
|
}
|
||||||
$setting['severity'] = 'warning';
|
if ($validationResult !== true) {
|
||||||
|
$setting['severity'] = $setting['severity'] ?? 'warning';
|
||||||
|
if (!in_array($setting['severity'], $this->severities)) {
|
||||||
|
$setting['severity'] = 'warning';
|
||||||
|
}
|
||||||
|
$setting['errorMessage'] = $validationResult;
|
||||||
}
|
}
|
||||||
$setting['errorMessage'] = $validationResult;
|
|
||||||
}
|
}
|
||||||
$setting['error'] = $validationResult !== true ? true : false;
|
$setting['error'] = $validationResult !== true ? true : false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -140,6 +140,7 @@ class CerebrateSettingsProvider extends BaseSettingsProvider
|
||||||
'type' => 'string',
|
'type' => 'string',
|
||||||
'description' => __('The hostname of an HTTP proxy for outgoing sync requests. Leave empty to not use a proxy.'),
|
'description' => __('The hostname of an HTTP proxy for outgoing sync requests. Leave empty to not use a proxy.'),
|
||||||
'test' => 'testHostname',
|
'test' => 'testHostname',
|
||||||
|
'empty' => true
|
||||||
],
|
],
|
||||||
'Proxy.port' => [
|
'Proxy.port' => [
|
||||||
'name' => __('Port'),
|
'name' => __('Port'),
|
||||||
|
@ -147,6 +148,7 @@ class CerebrateSettingsProvider extends BaseSettingsProvider
|
||||||
'type' => 'integer',
|
'type' => 'integer',
|
||||||
'description' => __('The TCP port for the HTTP proxy.'),
|
'description' => __('The TCP port for the HTTP proxy.'),
|
||||||
'test' => 'testForRangeXY',
|
'test' => 'testForRangeXY',
|
||||||
|
'empty' => true
|
||||||
],
|
],
|
||||||
'Proxy.user' => [
|
'Proxy.user' => [
|
||||||
'name' => __('User'),
|
'name' => __('User'),
|
||||||
|
@ -154,6 +156,7 @@ class CerebrateSettingsProvider extends BaseSettingsProvider
|
||||||
'description' => __('The authentication username for the HTTP proxy.'),
|
'description' => __('The authentication username for the HTTP proxy.'),
|
||||||
'default' => 'admin',
|
'default' => 'admin',
|
||||||
'dependsOn' => 'proxy.host',
|
'dependsOn' => 'proxy.host',
|
||||||
|
'empty' => true
|
||||||
],
|
],
|
||||||
'Proxy.password' => [
|
'Proxy.password' => [
|
||||||
'name' => __('Password'),
|
'name' => __('Password'),
|
||||||
|
@ -161,6 +164,7 @@ class CerebrateSettingsProvider extends BaseSettingsProvider
|
||||||
'description' => __('The authentication password for the HTTP proxy.'),
|
'description' => __('The authentication password for the HTTP proxy.'),
|
||||||
'default' => '',
|
'default' => '',
|
||||||
'dependsOn' => 'proxy.host',
|
'dependsOn' => 'proxy.host',
|
||||||
|
'empty' => true
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
|
|
Loading…
Reference in New Issue