- completed the implementaiton o the 'is dirty' flag to prevent reloading an object being modified.

- added a protection against reading an uninitialized field that triggered a PHP 'notice' error.

SVN:trunk[201]
This commit is contained in:
Denis Flaven
2009-12-21 19:16:27 +00:00
parent 89396151c5
commit 97761de870

View File

@@ -302,6 +302,7 @@ abstract class DBObject
}
}
$this->m_aCurrValues[$sAttCode] = $oAttDef->MakeRealValue($value);
$this->RegisterAsDirty(); // Make sure we do not reload it anymore... before saving it
}
public function Get($sAttCode)
@@ -310,13 +311,13 @@ abstract class DBObject
{
throw new CoreException("Unknown attribute code '$sAttCode' for the class ".get_class($this));
}
if ($this->m_bIsInDB && !$this->m_aLoadedAtt[$sAttCode])
if ($this->m_bIsInDB && !$this->m_aLoadedAtt[$sAttCode] && !$this->m_bDirty)
{
// #@# non-scalar attributes.... handle that differentely
$this->Reload();
}
$this->ComputeFields();
return $this->m_aCurrValues[$sAttCode];
return isset($this->m_aCurrValues[$sAttCode]) ? $this->m_aCurrValues[$sAttCode] : '';
}
public function GetOriginal($sAttCode)
@@ -696,6 +697,7 @@ abstract class DBObject
public function DBInsert()
{
$this->DBInsertNoReload();
$this->m_bDirty = false;
$this->Reload();
return $this->m_iKey;
}
@@ -741,9 +743,13 @@ abstract class DBObject
}
$this->DBWriteLinks();
$this->m_bDirty = false;
// Reload to get the external attributes
if ($bHasANewExternalKeyValue) $this->Reload();
if ($bHasANewExternalKeyValue)
{
$this->Reload();
}
return $this->m_iKey;
}