From d6379d5425ad9d31b64b439aa4af990f8154fd79 Mon Sep 17 00:00:00 2001 From: Tim Otten Date: Thu, 16 May 2013 18:43:21 -0400 Subject: [PATCH] CRM-12647 - Separate field-rewriting from XML encoding ---------------------------------------- * CRM-12647: Customization export/import crashes on "&" http://issues.civicrm.org/jira/browse/CRM-12647 --- CRM/Utils/Migrate/Export.php | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/CRM/Utils/Migrate/Export.php b/CRM/Utils/Migrate/Export.php index e4b6204069..4cb3fadb85 100644 --- a/CRM/Utils/Migrate/Export.php +++ b/CRM/Utils/Migrate/Export.php @@ -332,7 +332,8 @@ AND entity_id IS NULL function exportDAO($object, $objectName, $additional = NULL) { $dbFields = & $object->fields(); - $xml = " <$objectName>"; + // Filter the list of keys and values so that we only export interesting stuff + $keyValues = array(); foreach ($dbFields as $name => $dontCare) { // ignore all ids if ($name == 'id' || @@ -358,14 +359,14 @@ AND entity_id IS NULL elseif ($object->extends == 'Relationship') { $key = 'relationship_type'; } - $xml .= "\n " . $this->renderTextTag('extends_entity_column_value_option_group', $key); + $keyValues['extends_entity_column_value_option_group'] = $key; $types = explode(CRM_Core_DAO::VALUE_SEPARATOR, substr($object->$name, 1, -1)); $value = array(); foreach ($types as $type) { $values[] = $this->_xml['optionValue']['map']["$key.{$type}"]; } $value = implode(',', $values); - $xml .= "\n " . $this->renderTextTag('extends_entity_column_value_option_value', $value); + $keyValues['extends_entity_column_value_option_value'] = $value; } else { echo "This extension: {$object->extends} is not yet handled"; @@ -384,9 +385,15 @@ AND entity_id IS NULL else { $value = str_replace(CRM_Core_DAO::VALUE_SEPARATOR, self::XML_VALUE_SEPARATOR, $object->$name); } - $xml .= "\n " . $this->renderTextTag($name, $value); + $keyValues[$name] = $value; } } + + // We're ready to format $keyValues as XML + $xml = " <$objectName>"; + foreach ($keyValues as $k => $v) { + $xml .= "\n " . $this->renderTextTag($k, $v); + } if ($additional) { $xml .= $additional; } -- 2.25.1