Skip to content

Commit

Permalink
Merge branch 'hotfix-attr_download'
Browse files Browse the repository at this point in the history
  • Loading branch information
johnvanbreda committed Apr 6, 2022
2 parents 02f0061 + 389d608 commit a960624
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 10 deletions.
4 changes: 2 additions & 2 deletions application/config/version.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,15 @@
*
* @var string
*/
$config['version'] = '7.1.7';
$config['version'] = '7.1.8';


/**
* Version release date.
*
* @var string
*/
$config['release_date'] = '2022-03-30';
$config['release_date'] = '2022-04-06';


/**
Expand Down
28 changes: 20 additions & 8 deletions modules/rest_api/libraries/RestApiElasticsearch.php
Original file line number Diff line number Diff line change
Expand Up @@ -496,15 +496,22 @@ private function esGetSpecialFieldAttrValue(array $doc, array $params) {
// Tolerate sample or event for sample attributes.
$key = $params[0] === 'parent_event' ? 'parent_attributes' : 'attributes';
$entity = in_array($params[0], ['sample', 'event', 'parent_event']) ? 'event' : 'occurrence';
$attrList = [];
if (isset($doc[$entity][$key])) {
foreach ($doc[$entity][$key] as $attr) {
if ($attr['id'] == $params[1]) {
if (is_array($attr['value'])) {
$r = array_merge($r, $attr['value']);
}
else {
$r[] = $attr['value'];
}
$attrList = $doc[$entity][$key];
}
// If requesting an event/sample attribute, the parent event/sample's
// data can also be considered.
if ($entity === 'event' && $key === 'attributes' && isset($doc['event']['parent_attributes'])) {
$attrList = array_merge($attrList, $doc['event']['parent_attributes']);
}
foreach ($attrList as $attr) {
if ($attr['id'] == $params[1]) {
if (is_array($attr['value'])) {
$r = array_merge($r, $attr['value']);
}
else {
$r[] = $attr['value'];
}
}
}
Expand Down Expand Up @@ -1879,6 +1886,11 @@ private function getEsPostData($postObj, $format, $file, $isSearch) {
// Tolerate sample or event for entity parameter.
$entity = in_array($matches[1], ['sample', 'event', 'parent_event']) ? 'event' : 'occurrence';
$fields[] = "$entity.$key";
// When requesting an event attribute, allow the parent event
// attribute value to be used if necessary.
if ("$entity.$key" === 'event.attributes') {
$fields[] = 'event.parent_attributes';
}
}
elseif (preg_match('/^#null_if_zero:([a-z_]+(\.[a-z_]+)*)#$/', $field, $matches)) {
$fields[] = $matches[1];
Expand Down

0 comments on commit a960624

Please sign in to comment.