Support choosing the sort type when creating or editing a user query (#8954)

* Support choosing the sort type when creating or editing a user query

Changes
- User queries can now store a sort field (sort type), not only the sort
  direction. The create and edit forms expose a single combined dropdown
  (field + direction) that reuses the existing `index.menu.sort.*` options,
  matching the global reading-settings sort UI.
- The "Bookmark current query" action now also remembers the current sort
  field, where it previously kept only the order direction.
- Relabel the query sort control from "Sort by date" to "Sort by"; other
  languages are marked for re-translation (// TODO).
- Add a CHANGELOG entry and credit the contributor in CREDITS.

Implementation
- `FreshRSS_UserQuery`: add an optional `sort` property mirroring `order`
  (constructor parsing, `toArray()`, `getSort()` falling back to the user
  default sort, and a `hasParameters()` check).
- `configureController`: split the combined dropdown value into `sort` and
  `order`, validating the field against the implemented sort types
  (`id`, `c.name`, `date`, `f.name`, `length`, `link`, `title`, `rand`);
  separate `sort`/`order` request parameters are still accepted so the
  "bookmark current query" flow keeps working.
- Views render the combined dropdown and persist `sort` as a hidden field.
- `p/api/query.php`: back-fill `sort` from the saved query when the request
  does not provide one, mirroring the existing `order` handling.
- Add unit tests covering the sort round-trip and `toArray()` inclusion.

Compatibility
- No database or schema change: user queries are stored in the per-user PHP
  config array, which keeps arbitrary keys verbatim, so no migration is
  required.
- Upgrade: existing queries without `sort` fall back to the user default
  sort; behaviour is unchanged until a sort is explicitly chosen.
- Downgrade: older versions ignore the extra `sort` key and keep working;
  re-saving under an old version simply drops the key with no data loss.
- Shared query URLs without a `sort` parameter remain valid.

* Refresh README translation statistics

* i18n: fr

---------

Co-authored-by: Alexandre Alapetite <alexandre@alapetite.fr>
This commit is contained in:
i @manandAlexandre Alapetite authored and GitHub committed 2026-11-02 21:43:05 +01:00
1 parent d03296f074
commit 4e8a258b01
40 files changed
+160 -60

No files matched your search

+13
View File
@@ -88,6 +88,13 @@ class UserQueryTest extends TestCase {
self::assertSame($order, $user_query->getOrder());
}
public static function test__construct_whenSort_storesSort(): void {
$sort = 'title';
$query = ['sort' => $sort];
$user_query = new FreshRSS_UserQuery($query, [], []);
self::assertSame($sort, $user_query->getSort());
}
public static function test__construct_whenState_storesState(): void {
$state = FreshRSS_Entry::STATE_NOT_READ | FreshRSS_Entry::STATE_FAVORITE;
$query = ['state' => $state];
@@ -122,6 +129,12 @@ class UserQueryTest extends TestCase {
self::assertSame($query, $user_query->toArray());
}
public static function testToArray_whenSort_returnsSort(): void {
$query = ['sort' => 'date'];
$user_query = new FreshRSS_UserQuery($query, [], []);
self::assertSame('date', $user_query->toArray()['sort'] ?? null);
}
public static function testHasSearch_whenSearch_returnsTrue(): void {
$query = ['search' => 'some search'];
$user_query = new FreshRSS_UserQuery($query, [], []);