mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
BUGFIX: Memory usage improvements to CsvBulkLoader and Member::onBeforeWrite()
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/branches/2.3@72252 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
parent
9e32f24279
commit
5a602720e6
@ -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);
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user