fix: [tag search] fixes #1

- correctly break the execution for AND ed tag searches if at least one of the tags in the list doesn't exist
- correctly compare against the event_id field in the attribute_tags table, rather than the copy pasta error of Event.id
pull/9764/head
iglocska 2024-06-04 15:12:04 +02:00
parent 565b6a68c1
commit 5c80a22f1f
No known key found for this signature in database
GPG Key ID: BEA224F1FEF113AC
1 changed files with 7 additions and 1 deletions

View File

@ -1101,6 +1101,12 @@ class Attribute extends AppModel
$params[$tag_key] = $this->dissectArgs($params[$tag_key]);
foreach (array(0, 1, 2) as $tag_operator) {
$tagArray[$tag_operator] = $tag->fetchTagIdsSimple($params[$tag_key][$tag_operator]);
// If at least one of the ANDed tags is not found, invalidate the entire query by setting the lookup equal -1
if ($tag_operator === 2) {
if (count($params[$tag_key][2]) !== count($tagArray[2])) {
$tagArray[2] = [-1];
}
}
}
$temp = array();
if (!empty($tagArray[0])) {
@ -1200,7 +1206,7 @@ class Attribute extends AppModel
'tag_id' => $anded_tag
),
'fields' => array(
$options['scope'] === 'Event' ? 'Event.id' : 'attribute_id'
$options['scope'] === 'Event' ? 'event_id' : 'attribute_id'
)
);
$lookup_field = $options['scope'] === 'Event' ? 'Event.id' : 'Attribute.id';