When user searches `something SPACE SPACE something`, there is an empty keyword between the two spaces, which has to be ignored.
This also ignores the case of empty queries between double quotes, such as `""` or `" "`, because PostgreSQL Full Text Search does not support them.
* Make the 'Recently read' max age configurable via preference.
Also: don't attempt to filter by unread articles when using the 'Unread' view mode in the 'Recently read' feed.
* Rebase translations.
As indicated in the current help page, searching a date keyword does not work as expected due to UTC comparison.
For example, if the current time is November 18th at 16:14 UTC, then in Japan (GMT+9), it's November 19th at 01:14. A Japanese user who searches for _@yesterday_ means November 18th. However the current implementation uses _strtotime()_ with a default timezone of UTC, so _strtotime("yesterday")_ returns November 17th (because it's still the 18th in UK). There is a time shift after, but it can't solve this first issue. Then, a second issue is related to the conversion of the _updated_ SQL column to a string "YYYY-MM-DD", but there is no time shift.
I choose to fully rewrite this code, using the modern PHP DateTime class, and to use a _true_ Unix timestamp range, instead of a shifted timestamp.
A search query can now use _label:true_ to find articles with a label, whatever its name is.
A search query can now use _tag:true_ to find articles with a tag, whatever its name is.
This change is straightforward, because more complex queries about label/tag matching were already implemented.
By using two SQL fragments, there is no redundancy in the code.
When a search is performed, the found text should be highlighted.
However:
- successive words are not highlighted because the SQL query with "<->" is used
- operators are highlighted
tt-rss is currently supporting complex text search queries like _( one | two )_.
However, simple queries containing only _!_, _(_ or _)_ were not supported.
This is because the regexp only matched _&_ and _|_.
A search filter can for example contain spaces such as _title:" be "_.
In this case, the user as explicitly added spaces (instead of using _title:be_), so she clearly indicates her intent to search the word _be_, and not _cyBErspace_.
This patch supports these cases, for keywords title, author and notes.
Also, do a _mb_strtolower()_ globally, because it was in every keyword processing.
Also process the double quoting magic with a consistent regexp in the three needed cases. This change was needed because the previous regexp did not support leading spaces in the value part of a keyword pair.
When a user searches _-note:store_ the results now contains:
- articles with a note different of "store"
- articles with no notes
Indeed, the NULL case was not handled, so articles without a note were not displayed.
A known issue was that the Search Query _title_ was searched using LIKE instead of Full Text Search. It was the same for all keys of an invalid key pair. Solving this suppresses a lot of redundant code.
The Search Queries _start:false_, _pub:false_ and _unread:false_ are now checked.
If the check fails, the SQL error message is bold/strong to be more visible.
The Search Query _@invalid-date_ is now also searched as Full Text Search. Unfortunately, there is no error message, but document it in the source code.
The function _search_to_sql() processes the query string.
It contained a few bugs.
While analyzing it, I also added comments about the known limitations of this function.
* Pass in the profile so some preferences can be retrieved correctly.
* Consistently use the owner UID that gets passed in (previously some session var uses).
This introduces a helper to build a query part comparing a field against a past datetime (determined by '$now - $some_interval'), eliminating certain boilerplate code.