Skip to content

Commit 5d29ac1

Browse files
committed
fix: add custom setter for enabledIconTypes to normalize boolean values
1 parent f0f5c96 commit 5d29ac1

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

src/models/Settings.php

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,20 @@ public function validateLogLevel($attribute)
206206
}
207207
}
208208

209+
/**
210+
* Custom setter for enabledIconTypes to normalize boolean values
211+
* Converts string values ("1", "") to proper booleans (true, false)
212+
*/
213+
public function setEnabledIconTypes(array $value): void
214+
{
215+
// Normalize all values to booleans
216+
foreach ($value as $type => $enabled) {
217+
$value[$type] = filter_var($enabled, FILTER_VALIDATE_BOOLEAN);
218+
}
219+
220+
$this->enabledIconTypes = $value;
221+
}
222+
209223
/**
210224
* Get the resolved icon sets path
211225
*/
@@ -276,6 +290,14 @@ public static function loadFromDatabase(?Settings $settings = null): self
276290
// Decode JSON fields
277291
if (isset($row['enabledIconTypes'])) {
278292
$row['enabledIconTypes'] = Json::decode($row['enabledIconTypes']);
293+
294+
// Convert string values to booleans for strict comparison
295+
// Database may store "1"/"" instead of true/false
296+
if (is_array($row['enabledIconTypes'])) {
297+
foreach ($row['enabledIconTypes'] as $type => $enabled) {
298+
$row['enabledIconTypes'][$type] = filter_var($enabled, FILTER_VALIDATE_BOOLEAN);
299+
}
300+
}
279301
}
280302

281303
// Set attributes from database

0 commit comments

Comments
 (0)