#1921 - Make DataObject::write() call the recursive write on components, even when the dataobject itself hasn't changed

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@49180 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Sam Minnee 2008-02-07 03:26:41 +00:00
parent 7917df81ed
commit eda6a3b7e4

View File

@ -530,10 +530,7 @@ class DataObject extends Controller implements DataObjectInterface {
}
// No changes made
if(!$this->changed) {
return $this->record['ID'];
}
if($this->changed) {
foreach($this->getClassAncestry() as $ancestor) {
if(ClassInfo::hasTable($ancestor))
$ancestry[] = $ancestor;
@ -617,6 +614,12 @@ class DataObject extends Controller implements DataObjectInterface {
// Clears the cache for this object so get_one returns the correct object.
$this->flushCache();
if(!isset($this->record['Created'])) {
$this->record['Created'] = date('Y-m-d H:i:s');
}
$this->record['LastEdited'] = date('Y-m-d H:i:s');
}
// Write ComponentSets as necessary
if($this->components) {
foreach($this->components as $component) {
@ -624,11 +627,6 @@ class DataObject extends Controller implements DataObjectInterface {
}
}
if(!isset($this->record['Created'])) {
$this->record['Created'] = date('Y-m-d H:i:s');
}
$this->record['LastEdited'] = date('Y-m-d H:i:s');
return $this->record['ID'];
}