Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

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
  • Loading branch information...
commit 69928631fe918d13d27fd802d414084129fd9f93 1 parent 1a91431
@hafriedlander hafriedlander authored
Showing with 11 additions and 7 deletions.
  1. +11 −7 model/DataObject.php
View
18 model/DataObject.php
@@ -1920,7 +1920,15 @@ public function getField($field) {
if(self::is_composite_field($this->class, $field)) {
$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 @@ function setField($fieldName, $val) {
// 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->getField($fieldName);
$this->record[$fieldName] = $val;
// Situation 2: Passing a literal or non-DBField object
@@ -2120,9 +2126,7 @@ function setField($fieldName, $val) {
// 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->getField($fieldName);
// Value is always saved back when strict check succeeds.
$this->record[$fieldName] = $val;
Please sign in to comment.
Something went wrong with that request. Please try again.