diff options
| author | 2024-10-02 08:20:15 +0200 | |
|---|---|---|
| committer | 2024-10-02 08:20:15 +0200 | |
| commit | 2d0897ea747208356d8c70cc25e327d7f08c523c (patch) | |
| tree | 3965faf6c106772c5c2fa2faff56c43b769b67be /app/Models/BooleanSearch.php | |
| parent | 2489b6259ad334407c023eb60722c9746d973542 (diff) | |
Allow dynamic search operator in user queries (#6851)
* Allow dynamic search operator in user queries
fix https://github.com/FreshRSS/FreshRSS/issues/6849
* Other approach
Diffstat (limited to 'app/Models/BooleanSearch.php')
| -rw-r--r-- | app/Models/BooleanSearch.php | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/app/Models/BooleanSearch.php b/app/Models/BooleanSearch.php index b8e3af5e0..10c2321fb 100644 --- a/app/Models/BooleanSearch.php +++ b/app/Models/BooleanSearch.php @@ -31,12 +31,14 @@ class FreshRSS_BooleanSearch { if (!is_string($input)) { return; } + } + $this->raw_input = $input; + if ($level === 0) { $input = $this->parseUserQueryNames($input, $allowUserQueries); $input = $this->parseUserQueryIds($input, $allowUserQueries); $input = trim($input); } - $this->raw_input = $input; $input = self::consistentOrParentheses($input); @@ -58,11 +60,11 @@ class FreshRSS_BooleanSearch { } if (!empty($all_matches)) { - /** @var array<string,FreshRSS_UserQuery> */ $queries = []; foreach (FreshRSS_Context::userConf()->queries as $raw_query) { - $query = new FreshRSS_UserQuery($raw_query, FreshRSS_Context::categories(), FreshRSS_Context::labels()); - $queries[$query->getName()] = $query; + if (($raw_query['name'] ?? '') !== '' && ($raw_query['search'] ?? '') !== '') { + $queries[$raw_query['name']] = trim($raw_query['search']); + } } $fromS = []; @@ -76,7 +78,7 @@ class FreshRSS_BooleanSearch { if (!empty($queries[$name])) { $fromS[] = $matches[0][$i]; if ($allowUserQueries) { - $toS[] = '(' . trim($queries[$name]->getSearch()->getRawInput()) . ')'; + $toS[] = '(' . $queries[$name] . ')'; } else { $toS[] = ''; } @@ -100,11 +102,9 @@ class FreshRSS_BooleanSearch { } if (!empty($all_matches)) { - /** @var array<string,FreshRSS_UserQuery> */ $queries = []; foreach (FreshRSS_Context::userConf()->queries as $raw_query) { - $query = new FreshRSS_UserQuery($raw_query, FreshRSS_Context::categories(), FreshRSS_Context::labels()); - $queries[] = $query; + $queries[] = trim($raw_query['search'] ?? ''); } $fromS = []; @@ -119,7 +119,7 @@ class FreshRSS_BooleanSearch { if (!empty($queries[$id])) { $fromS[] = $matches[0][$i]; if ($allowUserQueries) { - $toS[] = '(' . trim($queries[$id]->getSearch()->getRawInput()) . ')'; + $toS[] = '(' . $queries[$id] . ')'; } else { $toS[] = ''; } |
