Skip to content

Commit 5af3236

Browse files
fix(ForeignModelField): always load from internal before returning
1 parent ce760dd commit 5af3236

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

pfSense-pkg-RESTAPI/files/usr/local/pkg/RESTAPI/Fields/ForeignModelField.inc

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -217,16 +217,16 @@ class ForeignModelField extends Field {
217217
* @return mixed The field value in its representation form.
218218
*/
219219
protected function _from_internal(mixed $internal_value): mixed {
220-
# If the model_field_internal, and the model_field are the same, return the internal value as-is.
221-
if ($this->model_field_internal === $this->model_field) {
222-
return $internal_value;
223-
}
224-
225220
# Ensure the internal field value is converted to its representation value before querying
226221
if ($this->model_field_internal !== 'id') {
227222
$internal_value = $this->models[0]->{$this->model_field_internal}->_from_internal($internal_value);
228223
}
229224

225+
# If the model_field_internal, and the model_field are the same, return the internal value as-is.
226+
if ($this->model_field_internal === $this->model_field) {
227+
return $internal_value;
228+
}
229+
230230
# Query for the Model object this value relates to.
231231
$query_modelset = $this->__get_matches($this->model_field_internal, $internal_value);
232232

0 commit comments

Comments
 (0)