diff --git a/model/DataObject.php b/model/DataObject.php index 82869dd5d..bec04bb5b 100644 --- a/model/DataObject.php +++ b/model/DataObject.php @@ -1377,6 +1377,12 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity // Check changes exist, abort if there are none $hasChanges = $this->updateChanges($isNewRecord); if($hasChanges || $forceWrite || $isNewRecord) { + + // Ensure Created and LastEdited are populated + if(!isset($this->record['Created'])) { + $this->record['Created'] = $now; + } + $this->record['LastEdited'] = $now; // New records have their insert into the base data table done first, so that they can pass the // generated primary key on to the rest of the manipulation $baseTable = ClassInfo::baseDataClass($this->class); @@ -1396,12 +1402,6 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity $this->invokeWithExtensions('onAfterSkippedWrite'); } - // Ensure Created and LastEdited are populated - if(!isset($this->record['Created'])) { - $this->record['Created'] = $now; - } - $this->record['LastEdited'] = $now; - // Write relations as necessary if($writeComponents) $this->writeComponents(true);