Merge pull request #13696 from marcusmoore/bug/sc-23796

Fixed potential call to a member function toArray() on null
This commit is contained in:
snipe 2023-10-03 11:01:40 +01:00 committed by GitHub
commit a2773aa895
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -21,6 +21,8 @@ class Field {
public static function makeArray(Field $field, Asset $asset) {
return $field->getOptions()
// filter out any FieldOptions that are accidentally null
->filter()
->map(fn($option) => $option->toArray($asset))
->filter(fn($result) => $result['value'] != null);
}
@ -36,4 +38,4 @@ class Field {
->map(fn($optionString) => FieldOption::fromString($optionString));
return $field;
}
}
}