mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
#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:
parent
7917df81ed
commit
eda6a3b7e4
@ -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'];
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user