mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
Merge pull request #1833 from oddnoc/1687-dataobject-forcewrite
FIX: Enable $forceWrite argument of DataObject#write()
This commit is contained in:
commit
65fd1a7ff4
@ -1123,7 +1123,7 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity
|
|||||||
}
|
}
|
||||||
|
|
||||||
// No changes made
|
// No changes made
|
||||||
if($this->changed) {
|
if($this->changed || $forceWrite) {
|
||||||
foreach($this->getClassAncestry() as $ancestor) {
|
foreach($this->getClassAncestry() as $ancestor) {
|
||||||
if(self::has_own_table($ancestor))
|
if(self::has_own_table($ancestor))
|
||||||
$ancestry[] = $ancestor;
|
$ancestry[] = $ancestor;
|
||||||
@ -1133,13 +1133,14 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity
|
|||||||
if(!$forceInsert) unset($this->changed['ID']);
|
if(!$forceInsert) unset($this->changed['ID']);
|
||||||
|
|
||||||
$hasChanges = false;
|
$hasChanges = false;
|
||||||
foreach($this->changed as $fieldName => $changed) {
|
if (!$forceWrite) {
|
||||||
if($changed) {
|
foreach ($this->changed as $fieldName => $changed) {
|
||||||
$hasChanges = true;
|
if ($changed) {
|
||||||
break;
|
$hasChanges = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if($hasChanges || $forceWrite || !$this->record['ID']) {
|
if($hasChanges || $forceWrite || !$this->record['ID']) {
|
||||||
|
|
||||||
// New records have their insert into the base data table done first, so that they can pass the
|
// New records have their insert into the base data table done first, so that they can pass the
|
||||||
|
Loading…
Reference in New Issue
Block a user