diff options
| author | 2025-12-17 10:07:52 +0100 | |
|---|---|---|
| committer | 2025-12-17 10:07:52 +0100 | |
| commit | 4bd503591469f47e710f1afbf0b5883f7770065d (patch) | |
| tree | 3f125f30b08b2d1a09063469543c974364deb331 /app/Models | |
| parent | 6952a13958417e8441645d0777597db679d0e28d (diff) | |
Rework encoding of search filters (#8324)
Rework:
* https://github.com/FreshRSS/FreshRSS/pull/8222
now that we have:
* https://github.com/FreshRSS/FreshRSS/pull/8293
Follow-up of:
* https://github.com/FreshRSS/FreshRSS/pull/8311
* More simplification
* Deprecate getRawInput
Diffstat (limited to 'app/Models')
| -rw-r--r-- | app/Models/BooleanSearch.php | 1 | ||||
| -rw-r--r-- | app/Models/FilterAction.php | 4 | ||||
| -rw-r--r-- | app/Models/FilterActionsTrait.php | 5 | ||||
| -rw-r--r-- | app/Models/Search.php | 1 | ||||
| -rw-r--r-- | app/Models/UserQuery.php | 4 |
5 files changed, 8 insertions, 7 deletions
diff --git a/app/Models/BooleanSearch.php b/app/Models/BooleanSearch.php index e959f7af9..6be189cda 100644 --- a/app/Models/BooleanSearch.php +++ b/app/Models/BooleanSearch.php @@ -525,6 +525,7 @@ class FreshRSS_BooleanSearch implements \Stringable { } /** @return string Plain text search query. Must be XML-encoded or URL-encoded depending on the situation */ + #[Deprecated('Use __tostring() instead')] public function getRawInput(): string { return $this->raw_input; } diff --git a/app/Models/FilterAction.php b/app/Models/FilterAction.php index 56c182904..5d11d26db 100644 --- a/app/Models/FilterAction.php +++ b/app/Models/FilterAction.php @@ -29,11 +29,11 @@ class FreshRSS_FilterAction { } } - /** @return array{'search'?:string,'actions'?:array<string>} */ + /** @return array{search?:string,actions?:array<string>} */ public function toJSON(): array { if (is_array($this->actions) && $this->booleanSearch != null) { return [ - 'search' => $this->booleanSearch->getRawInput(), + 'search' => $this->booleanSearch->__toString(), 'actions' => $this->actions, ]; } diff --git a/app/Models/FilterActionsTrait.php b/app/Models/FilterActionsTrait.php index 3c36343d6..819f2d975 100644 --- a/app/Models/FilterActionsTrait.php +++ b/app/Models/FilterActionsTrait.php @@ -71,8 +71,7 @@ trait FreshRSS_FilterActionsTrait { //Check existing filters for ($i = count($filterActions) - 1; $i >= 0; $i--) { $filterAction = $filterActions[$i]; - if ($filterAction == null || !is_array($filterAction->actions()) || - $filterAction->booleanSearch() == null || trim($filterAction->booleanSearch()->getRawInput()) == '') { + if ($filterAction === null || !is_array($filterAction->actions()) || $filterAction->booleanSearch()->__toString() === '') { array_splice($filterActions, $i, 1); continue; } @@ -86,7 +85,7 @@ trait FreshRSS_FilterActionsTrait { //Update existing filter with new action for ($k = count($filters) - 1; $k >= 0; $k--) { $filter = $filters[$k]; - if ($filter === $filterAction->booleanSearch()->getRawInput()) { + if ($filter === $filterAction->booleanSearch()->__toString()) { $actions[] = $action; array_splice($filters, $k, 1); } diff --git a/app/Models/Search.php b/app/Models/Search.php index 201fed9f9..046f61a2b 100644 --- a/app/Models/Search.php +++ b/app/Models/Search.php @@ -452,6 +452,7 @@ class FreshRSS_Search implements \Stringable { return trim($result); } + #[Deprecated('Use __tostring() instead')] public function getRawInput(): string { return $this->raw_input; } diff --git a/app/Models/UserQuery.php b/app/Models/UserQuery.php index 6050436f4..154f4d92c 100644 --- a/app/Models/UserQuery.php +++ b/app/Models/UserQuery.php @@ -123,7 +123,7 @@ class FreshRSS_UserQuery { 'get' => $this->get, 'name' => $this->name, 'order' => $this->order, - 'search' => $this->search->getRawInput(), + 'search' => $this->search->__toString(), 'state' => $this->state, 'url' => $this->url, 'token' => $this->token, @@ -221,7 +221,7 @@ class FreshRSS_UserQuery { * Check if there is a search in the search object */ public function hasSearch(): bool { - return $this->search->getRawInput() !== ''; + return $this->search->__toString() !== ''; } public function getGet(): string { |
