From 0ac9fce20795ec02c8146435ec8da3515758a07a Mon Sep 17 00:00:00 2001 From: Denis Flaven Date: Thu, 25 Jul 2013 09:24:18 +0000 Subject: [PATCH] #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] --- core/attributedef.class.inc.php | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/core/attributedef.class.inc.php b/core/attributedef.class.inc.php index 55a2b36822..1ffa37ec7f 100644 --- a/core/attributedef.class.inc.php +++ b/core/attributedef.class.inc.php @@ -3360,26 +3360,26 @@ class AttributeBlob extends AttributeDefinition public function FromSQLToValue($aCols, $sPrefix = '') { - if (!isset($aCols[$sPrefix])) + if (!array_key_exists($sPrefix, $aCols)) { $sAvailable = implode(', ', array_keys($aCols)); 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)); 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)); 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); return $value; @@ -4127,19 +4127,19 @@ class AttributeOneWayPassword extends AttributeDefinition public function FromSQLToValue($aCols, $sPrefix = '') { - if (!isset($aCols[$sPrefix])) + if (!array_key_exists($sPrefix, $aCols)) { $sAvailable = implode(', ', array_keys($aCols)); 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)); 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); return $value;