diff options
| author | 2024-08-01 19:44:58 +0200 | |
|---|---|---|
| committer | 2024-08-01 19:44:58 +0200 | |
| commit | 58de38bd737d2dba617944b54a98d4bdb5810588 (patch) | |
| tree | ff197baaabd4b3e12b29eb74f3d818d8f4a04e9a /app/Models/Entry.php | |
| parent | 666e7b27ce4f9c8254e76373572f220ddfb2fd37 (diff) | |
Fix parentheses for complex `OR` boolean search expressions (#6672)
* Fix OR parentheses
* Pass all tests
* Forgotten comment
* Minor whitespace
* Fix several cases envolving negation
* Line length
* Fix `OR NOT`
Diffstat (limited to 'app/Models/Entry.php')
| -rw-r--r-- | app/Models/Entry.php | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/app/Models/Entry.php b/app/Models/Entry.php index e4d728ba4..ada6e9944 100644 --- a/app/Models/Entry.php +++ b/app/Models/Entry.php @@ -577,12 +577,20 @@ HTML; foreach ($booleanSearch->searches() as $filter) { if ($filter instanceof FreshRSS_BooleanSearch) { // BooleanSearches are combined by AND (default) or OR or AND NOT (special cases) operators and are recursive - if ($filter->operator() === 'OR') { - $ok |= $this->matches($filter); - } elseif ($filter->operator() === 'AND NOT') { - $ok &= !$this->matches($filter); - } else { // AND - $ok &= $this->matches($filter); + switch ($filter->operator()) { + case 'OR': + $ok |= $this->matches($filter); + break; + case 'OR NOT': + $ok |= !$this->matches($filter); + break; + case 'AND NOT': + $ok &= !$this->matches($filter); + break; + case 'AND': + default: + $ok &= $this->matches($filter); + break; } } elseif ($filter instanceof FreshRSS_Search) { // Searches are combined by OR and are not recursive |
