#746 allow adding an AttributeBlob with is_null_allowed = true to an existing Data Model. (same issue fixed also for AttributeOneWayPassword).

SVN:2.0.1[2809]
This commit is contained in:
Denis Flaven
2013-07-25 09:24:18 +00:00
parent 8a8de2bcc3
commit 0ac9fce207

View File

@@ -3360,26 +3360,26 @@ class AttributeBlob extends AttributeDefinition
public function FromSQLToValue($aCols, $sPrefix = '') public function FromSQLToValue($aCols, $sPrefix = '')
{ {
if (!isset($aCols[$sPrefix])) if (!array_key_exists($sPrefix, $aCols))
{ {
$sAvailable = implode(', ', array_keys($aCols)); $sAvailable = implode(', ', array_keys($aCols));
throw new MissingColumnException("Missing column '$sPrefix' from {$sAvailable}"); throw new MissingColumnException("Missing column '$sPrefix' from {$sAvailable}");
} }
$sMimeType = $aCols[$sPrefix]; $sMimeType = isset($aCols[$sPrefix]) ? $aCols[$sPrefix] : '';
if (!isset($aCols[$sPrefix.'_data'])) if (!array_key_exists($sPrefix.'_data', $aCols))
{ {
$sAvailable = implode(', ', array_keys($aCols)); $sAvailable = implode(', ', array_keys($aCols));
throw new MissingColumnException("Missing column '".$sPrefix."_data' from {$sAvailable}"); throw new MissingColumnException("Missing column '".$sPrefix."_data' from {$sAvailable}");
} }
$data = $aCols[$sPrefix.'_data']; $data = isset($aCols[$sPrefix.'_data']) ? $aCols[$sPrefix.'_data'] : null;
if (!isset($aCols[$sPrefix.'_filename'])) if (!array_key_exists($sPrefix.'_filename', $aCols))
{ {
$sAvailable = implode(', ', array_keys($aCols)); $sAvailable = implode(', ', array_keys($aCols));
throw new MissingColumnException("Missing column '".$sPrefix."_filename' from {$sAvailable}"); throw new MissingColumnException("Missing column '".$sPrefix."_filename' from {$sAvailable}");
} }
$sFileName = $aCols[$sPrefix.'_filename']; $sFileName = isset($aCols[$sPrefix.'_filename']) ? $aCols[$sPrefix.'_filename'] : '';
$value = new ormDocument($data, $sMimeType, $sFileName); $value = new ormDocument($data, $sMimeType, $sFileName);
return $value; return $value;
@@ -4127,19 +4127,19 @@ class AttributeOneWayPassword extends AttributeDefinition
public function FromSQLToValue($aCols, $sPrefix = '') public function FromSQLToValue($aCols, $sPrefix = '')
{ {
if (!isset($aCols[$sPrefix])) if (!array_key_exists($sPrefix, $aCols))
{ {
$sAvailable = implode(', ', array_keys($aCols)); $sAvailable = implode(', ', array_keys($aCols));
throw new MissingColumnException("Missing column '$sPrefix' from {$sAvailable}"); throw new MissingColumnException("Missing column '$sPrefix' from {$sAvailable}");
} }
$hashed = $aCols[$sPrefix]; $hashed = isset($aCols[$sPrefix]) ? $aCols[$sPrefix] : '';
if (!isset($aCols[$sPrefix.'_salt'])) if (!array_key_exists($sPrefix.'_salt', $aCols))
{ {
$sAvailable = implode(', ', array_keys($aCols)); $sAvailable = implode(', ', array_keys($aCols));
throw new MissingColumnException("Missing column '".$sPrefix."_salt' from {$sAvailable}"); throw new MissingColumnException("Missing column '".$sPrefix."_salt' from {$sAvailable}");
} }
$sSalt = $aCols[$sPrefix.'_salt']; $sSalt = isset($aCols[$sPrefix.'_salt']) ? $aCols[$sPrefix.'_salt'] : '';
$value = new ormPassword($hashed, $sSalt); $value = new ormPassword($hashed, $sSalt);
return $value; return $value;