Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(dev/core#2466) - Drop HTML markup in exports for link custom fields #19839

Merged
merged 1 commit into from
Mar 19, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CRM/Export/BAO/ExportProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -1120,6 +1120,11 @@ public function getTransformedFieldValue($field, $iterationDAO, $fieldValue, $pa
return $result['values'][$result['id']]['url'];
}

// Do not export HTML markup for links
if ($html_type === 'Link' && $fieldValue) {
return $fieldValue;
}

return CRM_Core_BAO_CustomField::displayValue($fieldValue, $cfID);
}
elseif (in_array($field, [
Expand Down
4 changes: 4 additions & 0 deletions tests/phpunit/CRM/Export/BAO/ExportTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -734,19 +734,22 @@ public function testExportCustomData() {
$longString .= 'Blah';
}
$this->addOptionToCustomField('select_string', ['label' => $longString, 'name' => 'blah']);
$longUrl = 'https://stage.example.org/system/files/webform/way_too_long_url_that_still_fits_in_a_link_custom_field_but_would_fail_to_export_with_html.jpg';

$this->callAPISuccess('Contact', 'create', [
'id' => $this->contactIDs[1],
$this->getCustomFieldName('text') => $longString,
$this->getCustomFieldName('country') => 'LA',
$this->getCustomFieldName('select_string') => 'blah',
'api.Address.create' => ['location_type_id' => 'Billing', 'city' => 'Waipu'],
$this->getCustomFieldName('link') => $longUrl,
]);
$selectedFields = [
['name' => 'city', 'location_type_id' => CRM_Core_PseudoConstant::getKey('CRM_Core_BAO_Address', 'location_type_id', 'Billing')],
['name' => $this->getCustomFieldName('text')],
['name' => $this->getCustomFieldName('country')],
['name' => $this->getCustomFieldName('select_string')],
['name' => $this->getCustomFieldName('link')],
];

$this->doExportTest([
Expand All @@ -758,6 +761,7 @@ public function testExportCustomData() {
$this->assertEquals('Waipu', $row['Billing-City']);
$this->assertEquals("Lao People's Democratic Republic", $row['Country']);
$this->assertEquals($longString, $row['Pick Color']);
$this->assertEquals($longUrl, $row['test_link']);
}

/**
Expand Down