diff --git a/core/model/DataObject.php b/core/model/DataObject.php index 5ba1a7ee7..2f47dfdee 100644 --- a/core/model/DataObject.php +++ b/core/model/DataObject.php @@ -179,6 +179,9 @@ class DataObject extends ViewableData implements DataObjectInterface,i18nEntityP $this->extension_instances = null; $this->components = null; $this->destroyed = true; + $this->record = null; + $this->orignal = null; + $this->changed = null; $this->flushCache(); } @@ -713,7 +716,7 @@ class DataObject extends ViewableData implements DataObjectInterface,i18nEntityP return false; } } - + $this->onBeforeWrite(); if($this->brokenOnWrite) { user_error("$this->class has a broken onBeforeWrite() function. Make sure that you call parent::onBeforeWrite().", E_USER_ERROR); diff --git a/dev/CsvBulkLoader.php b/dev/CsvBulkLoader.php index b2f38bb77..c0d59ed53 100644 --- a/dev/CsvBulkLoader.php +++ b/dev/CsvBulkLoader.php @@ -86,6 +86,7 @@ class CsvBulkLoader extends BulkLoader { $obj->setComponent($relationName, $relationObj); $obj->{"{$relationName}ID"} = $relationObj->ID; $obj->write(); + $obj->flushCache(); // avoid relation caching confusion } elseif(strpos($fieldName, '.') !== false) { // we have a relation column with dot notation @@ -95,11 +96,10 @@ class CsvBulkLoader extends BulkLoader { $relationObj->write(); $obj->{"{$relationName}ID"} = $relationObj->ID; $obj->write(); + $obj->flushCache(); // avoid relation caching confusion } - $obj->flushCache(); // avoid relation caching confusion } - $id = ($preview) ? 0 : $obj->write(); // second run: save data foreach($record as $fieldName => $val) { @@ -127,9 +127,15 @@ class CsvBulkLoader extends BulkLoader { $results->addCreated($obj, $message); } + $objID = $obj->ID; + + $obj->destroy(); + // memory usage unset($existingObj); unset($obj); + + return $objID; } /** diff --git a/security/Member.php b/security/Member.php index 2807a13bf..51fe36a0f 100644 --- a/security/Member.php +++ b/security/Member.php @@ -452,7 +452,6 @@ class Member extends DataObject { */ function onBeforeWrite() { if($this->SetPassword) $this->Password = $this->SetPassword; - $identifierField = self::$unique_identifier_field; if($this->$identifierField) { $idClause = ($this->ID) ? " AND `Member`.ID <> $this->ID" : ''; @@ -470,6 +469,7 @@ class Member extends DataObject { foreach($existingRecord->getAllFields() as $k => $v) { if(!isset($this->changed[$k]) || !$this->changed[$k]) $this->record[$k] = $v; } + $existingRecord->destroy(); } }