BUG trac 7482, we werent unlazying composite fields right

In getField we check if the field we are getting is currently lazy (unloaded), and
load it if it is. This was only working for simple fields though - composite
fields like Money werent working
This commit is contained in:
Hamish Friedlander 2012-07-18 16:25:37 +12:00
parent 1a91431d39
commit 69928631fe

View File

@ -1921,6 +1921,14 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity
$helper = $this->castingHelper($field);
$fieldObj = Object::create_from_string($helper, $field);
$compositeFields = $fieldObj->compositeDatabaseFields();
foreach ($compositeFields as $compositeName => $compositeType) {
if(isset($this->record[$field.$compositeName.'_Lazy'])) {
$tableClass = $this->record[$field.$compositeName.'_Lazy'];
$this->loadLazyFields($tableClass);
}
}
// write value only if either the field value exists,
// or a valid record has been loaded from the database
$value = (isset($this->record[$field])) ? $this->record[$field] : null;
@ -2092,9 +2100,7 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity
// If we've just lazy-loaded the column, then we need to populate the $original array by
// called getField(). Too much overhead? Could this be done by a quicker method? Maybe only
// on a call to getChanged()?
if (isset($this->record[$fieldName.'_Lazy'])) {
$this->getField($fieldName);
}
$this->record[$fieldName] = $val;
// Situation 2: Passing a literal or non-DBField object
@ -2120,9 +2126,7 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity
// If we've just lazy-loaded the column, then we need to populate the $original array by
// called getField(). Too much overhead? Could this be done by a quicker method? Maybe only
// on a call to getChanged()?
if (isset($this->record[$fieldName.'_Lazy'])) {
$this->getField($fieldName);
}
// Value is always saved back when strict check succeeds.
$this->record[$fieldName] = $val;