fix: [tag filters] fixed a bug introduced with the previous filter fix, resulting in multiple OR tags being ignored as a valid filter

pull/6315/head
iglocska 2020-09-12 11:54:49 +02:00
parent 899490969c
commit 5d3dee3ba2
No known key found for this signature in database
GPG Key ID: BEA224F1FEF113AC
1 changed files with 4 additions and 2 deletions

View File

@ -468,6 +468,7 @@ class EventsController extends AppController
$filterString = "";
$expectOR = false;
$setOR = false;
$tagRules = [];
foreach ($pieces as $piece) {
if ($piece[0] == '!') {
if (is_numeric(substr($piece, 1))) {
@ -498,7 +499,7 @@ class EventsController extends AppController
foreach ($block as $b) {
$sqlSubQuery .= $b['EventTag']['event_id'] . ',';
}
$this->paginate['conditions']['AND'][] = substr($sqlSubQuery, 0, -1) . ')';
$tagRules['AND'][] = substr($sqlSubQuery, 0, -1) . ')';
}
if ($filterString != "") {
$filterString .= "|";
@ -536,7 +537,7 @@ class EventsController extends AppController
$setOR = true;
$sqlSubQuery .= $a['EventTag']['event_id'] . ',';
}
$this->paginate['conditions']['AND'][] = substr($sqlSubQuery, 0, -1) . ')';
$tagRules['OR'][] = substr($sqlSubQuery, 0, -1) . ')';
}
if ($filterString != "") {
$filterString .= "|";
@ -544,6 +545,7 @@ class EventsController extends AppController
$filterString .= isset($tagName['Tag']['name']) ? $tagName['Tag']['name'] : $piece;
}
}
$this->paginate['conditions']['AND'][] = $tagRules;
// If we have a list of OR-d arguments, we expect to end up with a list of allowed event IDs
// If we don't however, it means that none of the tags was found. To prevent displaying the entire event index in this case:
if ($expectOR && !$setOR) {