fixes bug in discovered while running migrate02to021 script

pull/61/head
Christophe Vandeplas 2012-04-25 13:56:25 +02:00
parent 6e9f0f0d24
commit 97a5790938
1 changed files with 11 additions and 9 deletions

View File

@ -183,15 +183,17 @@ class Attribute extends AppModel {
// explode value of composite type in value1 and value2
// or copy value to value1 if not composite type
$composite_types = $this->getCompositeTypes();
if (in_array($this->data['Attribute']['type'], $composite_types)) {
// explode composite types in value1 and value2
$pieces = explode('|', $this->data['Attribute']['value']);
if (2 != sizeof($pieces)) throw new InternalErrorException('Composite type, but value not explodable');
$this->data['Attribute']['value1'] = $pieces[0];
$this->data['Attribute']['value2'] = $pieces[1];
} else {
$this->data['Attribute']['value1'] = $this->data['Attribute']['value'];
if (!empty($this->data['Attribute']['type'])) {
$composite_types = $this->getCompositeTypes();
if (in_array($this->data['Attribute']['type'], $composite_types)) {
// explode composite types in value1 and value2
$pieces = explode('|', $this->data['Attribute']['value']);
if (2 != sizeof($pieces)) throw new InternalErrorException('Composite type, but value not explodable');
$this->data['Attribute']['value1'] = $pieces[0];
$this->data['Attribute']['value2'] = $pieces[1];
} else {
$this->data['Attribute']['value1'] = $this->data['Attribute']['value'];
}
}
// always return true after a beforeSave()