From a7bb5c7767026f955d8ac549586d35a1a2abd282 Mon Sep 17 00:00:00 2001 From: Andras Iklody Date: Tue, 26 Feb 2013 15:38:08 +0100 Subject: [PATCH] Composite type change - composite type's value not exploded if value1 already set (to hopefully fix issues with the migration tool) --- app/Model/Attribute.php | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/app/Model/Attribute.php b/app/Model/Attribute.php index e5f7b4493..6d661f208 100755 --- a/app/Model/Attribute.php +++ b/app/Model/Attribute.php @@ -369,17 +369,19 @@ class Attribute extends AppModel { if (!empty($this->data['Attribute']['type'])) { $compositeTypes = $this->getCompositeTypes(); // explode composite types in value1 and value2 - $pieces = explode('|', $this->data['Attribute']['value']); - if (in_array($this->data['Attribute']['type'], $compositeTypes)) { - if (2 != count($pieces)) { - throw new InternalErrorException('Composite type, but value not explodable'); + if (!isset($this->data['Attribute']['value1'])) { + $pieces = explode('|', $this->data['Attribute']['value']); + if (in_array($this->data['Attribute']['type'], $compositeTypes)) { + if (2 != count($pieces)) { + throw new InternalErrorException('Composite type, but value not explodable'); + } + $this->data['Attribute']['value1'] = $pieces[0]; + $this->data['Attribute']['value2'] = $pieces[1]; + } else { + $total = implode('|', $pieces); + $this->data['Attribute']['value1'] = $total; + $this->data['Attribute']['value2'] = ''; } - $this->data['Attribute']['value1'] = $pieces[0]; - $this->data['Attribute']['value2'] = $pieces[1]; - } else { - $total = implode('|', $pieces); - $this->data['Attribute']['value1'] = $total; - $this->data['Attribute']['value2'] = ''; } } // always return true after a beforeSave()