FIX LastEdited no longer updated on skipped writes

This commit is contained in:
Daniel Hensby 2017-08-16 23:12:08 +01:00
parent 1ae07ac2a3
commit eb80a5f9e8
No known key found for this signature in database
GPG Key ID: B00D1E9767F0B06E

View File

@ -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);