FIX: Fix latent bug in DataObject

This didn’t show up until we ran tests on PHP 7.3-dev
This commit is contained in:
Sam Minnee 2017-08-15 11:12:39 +12:00
parent 0eebeedd03
commit 0926b04512

View File

@ -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 ($i<sizeof($relation)-1 && !$relObj->ID || (!$relObj->ID && $parentObj !== $this)) {
// If the intermediate relationship objects haven't been created, then write them
if ($i<sizeof($relations)-1 && !$relObj->ID || (!$relObj->ID && $parentObj !== $this)) {
$relObj->write();
$relatedFieldName = $relation."ID";
$parentObj->$relatedFieldName = $relObj->ID;