Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

FIX: Enable $forceWrite argument of DataObject#write()

$forceWrite was being ignored because it was tested in a part of the
code that is reachable if and only if there are changes to the object.
This patch adds an additional test to correct that logic error.

Also, refrain from needlessly checking for changes when $forceWrite is
true.

Fixes #1687
  • Loading branch information...
commit ea7b94206d4fd7d1920fc7bab695e595a5fb5894 1 parent 7fbb9e3
Fred Condo authored
Showing with 7 additions and 6 deletions.
  1. +7 −6 model/DataObject.php
View
13 model/DataObject.php
@@ -1123,7 +1123,7 @@ public function write($showDebug = false, $forceInsert = false, $forceWrite = fa
}
// No changes made
- if($this->changed) {
+ if($this->changed || $forceWrite) {
foreach($this->getClassAncestry() as $ancestor) {
if(self::has_own_table($ancestor))
$ancestry[] = $ancestor;
@@ -1133,13 +1133,14 @@ public function write($showDebug = false, $forceInsert = false, $forceWrite = fa
if(!$forceInsert) unset($this->changed['ID']);
$hasChanges = false;
- foreach($this->changed as $fieldName => $changed) {
- if($changed) {
- $hasChanges = true;
- break;
+ if (!$forceWrite) {
+ foreach ($this->changed as $fieldName => $changed) {
+ if ($changed) {
+ $hasChanges = true;
+ break;
+ }
}
}
-
if($hasChanges || $forceWrite || !$this->record['ID']) {
// New records have their insert into the base data table done first, so that they can pass the
Please sign in to comment.
Something went wrong with that request. Please try again.