diff --git a/src/ORM/DataObject.php b/src/ORM/DataObject.php index 0e1c7b7aa..927ad9ad0 100644 --- a/src/ORM/DataObject.php +++ b/src/ORM/DataObject.php @@ -807,8 +807,8 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity if ($relObj->$relation() instanceof DataObject) { $parentObj = $relObj; $relObj = $relObj->$relation(); - // If the intermediate relationship objects have been created, then write them - if ($iID || (!$relObj->ID && $parentObj !== $this)) { + // If the intermediate relationship objects haven't been created, then write them + if ($iID || (!$relObj->ID && $parentObj !== $this)) { $relObj->write(); $relatedFieldName = $relation."ID"; $parentObj->$relatedFieldName = $relObj->ID;