Skip to content

Commit a2773aa

Browse files
authored
Merge pull request #13696 from marcusmoore/bug/sc-23796
Fixed potential call to a member function toArray() on null
2 parents 1abcc8b + e82fec2 commit a2773aa

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

app/Models/Labels/Field.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ public function toArray(Asset $asset) { return Field::makeArray($this, $asset);
2121

2222
public static function makeArray(Field $field, Asset $asset) {
2323
return $field->getOptions()
24+
// filter out any FieldOptions that are accidentally null
25+
->filter()
2426
->map(fn($option) => $option->toArray($asset))
2527
->filter(fn($result) => $result['value'] != null);
2628
}
@@ -36,4 +38,4 @@ public static function fromString(string $theString) {
3638
->map(fn($optionString) => FieldOption::fromString($optionString));
3739
return $field;
3840
}
39-
}
41+
}

0 commit comments

Comments
 (0)