Skip to content

Commit

Permalink
Merge pull request #13696 from marcusmoore/bug/sc-23796
Browse files Browse the repository at this point in the history
Fixed potential call to a member function toArray() on null
  • Loading branch information
snipe authored Oct 3, 2023
2 parents 1abcc8b + e82fec2 commit a2773aa
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion app/Models/Labels/Field.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ public function toArray(Asset $asset) { return Field::makeArray($this, $asset);

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);
}
Expand All @@ -36,4 +38,4 @@ public static function fromString(string $theString) {
->map(fn($optionString) => FieldOption::fromString($optionString));
return $field;
}
}
}

0 comments on commit a2773aa

Please sign in to comment.