Skip to content

Commit ac4dc2b

Browse files
committed
fix: fix checking for empty value when getting system settings
1 parent afb4cbd commit ac4dc2b

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

core/components/modai/src/Settings.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@ private static function getOption(modX $modx, string $namespace, string $field,
1515
{
1616
if (!empty($field)) {
1717
$value = $modx->getOption("$namespace.$field.$area.$setting");
18-
if (!empty($value)) {
18+
if ($value !== null && $value !== '') {
1919
return $value;
2020
}
2121
}
2222

2323
$value = $modx->getOption("$namespace.global.$area.$setting");
24-
if (!empty($value)) {
24+
if ($value !== null && $value !== '') {
2525
return $value;
2626
}
2727

@@ -31,13 +31,13 @@ private static function getOption(modX $modx, string $namespace, string $field,
3131

3232
if (!empty($field)) {
3333
$value = $modx->getOption("modai.$field.$area.$setting");
34-
if (!empty($value)) {
34+
if ($value !== null && $value !== '') {
3535
return $value;
3636
}
3737
}
3838

3939
$value = $modx->getOption("modai.global.$area.$setting");
40-
if (!empty($value)) {
40+
if ($value !== null && $value !== '') {
4141
return $value;
4242
}
4343

@@ -51,7 +51,7 @@ public static function getTextSetting(modX $modx, string $field, string $setting
5151
{
5252
$value = self::getOption($modx, $namespace, $field, 'text', $setting);
5353

54-
if ($required && empty($value)) {
54+
if ($required && ($value === null || $value === '')) {
5555
throw new RequiredSettingException("modai.global.text.$setting");
5656
}
5757

@@ -65,7 +65,7 @@ public static function getImageSetting(modX $modx, string $field, string $settin
6565
{
6666
$value = self::getOption($modx, $namespace, $field, 'image', $setting);
6767

68-
if ($required && empty($value)) {
68+
if ($required && ($value === null || $value === '')) {
6969
throw new RequiredSettingException("modai.global.image.$setting");
7070
}
7171

@@ -79,7 +79,7 @@ public static function getVisionSetting(modX $modx, string $field, string $setti
7979
{
8080
$value = self::getOption($modx, $namespace, $field, 'vision', $setting);
8181

82-
if ($required && empty($value)) {
82+
if ($required && ($value === null || $value === '')) {
8383
throw new RequiredSettingException("modai.global.vision.$setting");
8484
}
8585

0 commit comments

Comments
 (0)