Fix undefined filter check in db_object_t trait logic

Ensure the filter is set before validating its value against allowed options. This prevents potential undefined index errors when filters are not provided.
This commit is contained in:
Jepp9350
2025-02-28 11:04:22 +01:00
parent 72df11e345
commit 7497e0c744
+2 -1
View File
@@ -408,7 +408,8 @@ trait db_object_t
foreach ( $fieldsAndValues as $field => $value ) {
// If the value is an array, check if the user tries to search for a different value than the ones provided
if (is_array($value)) {
if (!in_array($filters[$field], $value)) {
// Check if the filter is even set
if (isset($filters[$field]) && !in_array($filters[$field], $value)) {
throw new Exception('Invalid filter: ' . $field . ' - ' . $filters[$field] . '. Permitted values: ' . implode(', ', $value));
}
continue;