<feed xmlns='http://www.w3.org/2005/Atom'>
<title>FreshRSS (Customized)/app/Models/EntryDAOSQLite.php, branch edge</title>
<subtitle>Customized version of FreshRSS, a self-hosted RSS feed aggregator</subtitle>
<id>https://git.rdnlsmith.com/fresh-rss-custom/atom?h=edge</id>
<link rel='self' href='https://git.rdnlsmith.com/fresh-rss-custom/atom?h=edge'/>
<link rel='alternate' type='text/html' href='https://git.rdnlsmith.com/fresh-rss-custom/'/>
<updated>2025-12-25T10:31:07+00:00</updated>
<entry>
<title>DB: auto-add lastUserModified column also during markRead (#8346)</title>
<updated>2025-12-25T10:31:07+00:00</updated>
<author>
<name>Alexandre Alapetite</name>
<email>alexandre@alapetite.fr</email>
</author>
<published>2025-12-25T10:31:07+00:00</published>
<link rel='alternate' type='text/html' href='https://git.rdnlsmith.com/fresh-rss-custom/commit/?id=6fb5263633ce318432cf3d177539cbd574e0fce2'/>
<id>urn:sha1:6fb5263633ce318432cf3d177539cbd574e0fce2</id>
<content type='text'>
fix https://github.com/FreshRSS/FreshRSS/issues/8345</content>
</entry>
<entry>
<title>Fix MySQL commitNewEntries (#8223)</title>
<updated>2025-11-17T12:46:28+00:00</updated>
<author>
<name>Alexandre Alapetite</name>
<email>alexandre@alapetite.fr</email>
</author>
<published>2025-11-17T12:46:28+00:00</published>
<link rel='alternate' type='text/html' href='https://git.rdnlsmith.com/fresh-rss-custom/commit/?id=419a1978b6d8052f88783a4624cd17602422030a'/>
<id>urn:sha1:419a1978b6d8052f88783a4624cd17602422030a</id>
<content type='text'>
I just realised that `commitNewEntries()` was not sorting articles properly before insertion in database when using MySQL: Articles were not sorted by publication date as expected from the temporary table before insertion in the final table. MySQL was not picking the correct field, so fixed with an explicit alias.
Discovered because I did some tests with MySQL in https://github.com/FreshRSS/FreshRSS/pull/6957
At the same time, I did the same change for PostgreSQL and SQLite although those were not affected.</content>
</entry>
<entry>
<title>Fix SQLite GREATEST() (#8118)</title>
<updated>2025-10-14T21:56:57+00:00</updated>
<author>
<name>Alexandre Alapetite</name>
<email>alexandre@alapetite.fr</email>
</author>
<published>2025-10-14T21:56:57+00:00</published>
<link rel='alternate' type='text/html' href='https://git.rdnlsmith.com/fresh-rss-custom/commit/?id=1b8bc1ae8b9810eb66ff798093b89d2ce690373f'/>
<id>urn:sha1:1b8bc1ae8b9810eb66ff798093b89d2ce690373f</id>
<content type='text'>
* Fix SQLite GREATEST()
fix https://github.com/FreshRSS/FreshRSS/pull/8105
Related to https://github.com/FreshRSS/FreshRSS/pull/7886
</content>
</entry>
<entry>
<title>Last user modified (#7886)</title>
<updated>2025-10-10T22:43:38+00:00</updated>
<author>
<name>Federico Scodelaro</name>
<email>federicoscodelaro@gmail.com</email>
</author>
<published>2025-10-10T22:43:38+00:00</published>
<link rel='alternate' type='text/html' href='https://git.rdnlsmith.com/fresh-rss-custom/commit/?id=673067a52d44cbfc14327d226f4f1c4ce66f737a'/>
<id>urn:sha1:673067a52d44cbfc14327d226f4f1c4ce66f737a</id>
<content type='text'>
* feat: Add user modified functionality

Closes https://github.com/FreshRSS/FreshRSS/issues/7862

Changes proposed in this pull request:

This is an implementation of the proposed feature. It allows entries to have a new field that will be updated whenever an item is marked as read/unread or bookmark/removed from bookmarks. And a new sort criteria to sort by it.

How to test the feature manually:

1. Mark items from a feed as read/unread
2. Mark items from a feed as bookmark / remove bookmark
3. Sort by the new criteria

* feat: Add sort functionality
* feat: Add sort nav button
* fix: Use correct migrations
* fix: Add internationalization
* fix: Linter errors
* chore: PR comments

* Update app/i18n/fr/index.php
Co-authored-by: Alexandre Alapetite &lt;alexandre@alapetite.fr&gt;

* Update app/i18n/pl/index.php
Co-authored-by: Inverle &lt;inverle@proton.me&gt;

* Update app/i18n/nl/index.php
Co-authored-by: Frans de Jonge &lt;fransdejonge@gmail.com&gt;

* make fix-all
* Fixes
* More fixes sort
* Fix wrong index
* Fix unneeded column
* Fix auto-create indexes
* Some copilot suggestions
* One more fix
Co-authored-by: Alexandre Alapetite &lt;alexandre@alapetite.fr&gt;

---------

Co-authored-by: Alexandre Alapetite &lt;alexandre@alapetite.fr&gt;
Co-authored-by: Inverle &lt;inverle@proton.me&gt;
Co-authored-by: Frans de Jonge &lt;fransdejonge@gmail.com&gt;
</content>
</entry>
<entry>
<title>Recovery: skip broken entries during CLI export/import (#7949)</title>
<updated>2025-09-14T20:36:01+00:00</updated>
<author>
<name>Alexandre Alapetite</name>
<email>alexandre@alapetite.fr</email>
</author>
<published>2025-09-14T20:36:01+00:00</published>
<link rel='alternate' type='text/html' href='https://git.rdnlsmith.com/fresh-rss-custom/commit/?id=29446a29f58b484817e6c9798c736e5f531c21ee'/>
<id>urn:sha1:29446a29f58b484817e6c9798c736e5f531c21ee</id>
<content type='text'>
* Recovery: skip broken entries during CLI export/import
fix https://github.com/FreshRSS/FreshRSS/discussions/7927

```
25605/25605 (48 broken)
```

Help with *database malformed* or other corruption.

* Compatibility multiple databases</content>
</entry>
<entry>
<title>Fix newest articles not shown (#7577)</title>
<updated>2025-05-10T21:17:25+00:00</updated>
<author>
<name>Alexandre Alapetite</name>
<email>alexandre@alapetite.fr</email>
</author>
<published>2025-05-10T21:17:25+00:00</published>
<link rel='alternate' type='text/html' href='https://git.rdnlsmith.com/fresh-rss-custom/commit/?id=532d229d3396817f702c1ecae79fb7f9bdad9a64'/>
<id>urn:sha1:532d229d3396817f702c1ecae79fb7f9bdad9a64</id>
<content type='text'>
* Fix newest articles not shown
Case when processing was faster than 1 second.
fix https://github.com/FreshRSS/FreshRSS/issues/7412
Regression from https://github.com/FreshRSS/FreshRSS/pull/7149

* Simplify uTimeString()
PHPStan has become a bit smarter</content>
</entry>
<entry>
<title>Reduce undeeded use of elvis operator ?: (#7204)</title>
<updated>2025-01-10T07:13:09+00:00</updated>
<author>
<name>Alexandre Alapetite</name>
<email>alexandre@alapetite.fr</email>
</author>
<published>2025-01-10T07:13:09+00:00</published>
<link rel='alternate' type='text/html' href='https://git.rdnlsmith.com/fresh-rss-custom/commit/?id=5368f38753a3e655ed3d7d7dfc7af2cc22de7980'/>
<id>urn:sha1:5368f38753a3e655ed3d7d7dfc7af2cc22de7980</id>
<content type='text'>
</content>
</entry>
<entry>
<title>Add some missing PHP native types (#7191)</title>
<updated>2025-01-08T12:26:09+00:00</updated>
<author>
<name>Alexandre Alapetite</name>
<email>alexandre@alapetite.fr</email>
</author>
<published>2025-01-08T12:26:09+00:00</published>
<link rel='alternate' type='text/html' href='https://git.rdnlsmith.com/fresh-rss-custom/commit/?id=50adb559823f935582f3ed308b8d4352c5f216ed'/>
<id>urn:sha1:50adb559823f935582f3ed308b8d4352c5f216ed</id>
<content type='text'>
* Add some missing PHP native types
Replaces https://github.com/FreshRSS/FreshRSS/pull/7184

* Clean some types</content>
</entry>
<entry>
<title>Implement custom order-by (#7149)</title>
<updated>2025-01-06T15:00:00+00:00</updated>
<author>
<name>Alexandre Alapetite</name>
<email>alexandre@alapetite.fr</email>
</author>
<published>2025-01-06T15:00:00+00:00</published>
<link rel='alternate' type='text/html' href='https://git.rdnlsmith.com/fresh-rss-custom/commit/?id=1f466d7a2e6c8488d69012b40b40a5c1ed6ff4aa'/>
<id>urn:sha1:1f466d7a2e6c8488d69012b40b40a5c1ed6ff4aa</id>
<content type='text'>
Add option to sort results by received date (existing, default), publication date, title, URL (link), random.

fix https://github.com/FreshRSS/FreshRSS/issues/1771
fix https://github.com/FreshRSS/FreshRSS/issues/2083
fix https://github.com/FreshRSS/FreshRSS/issues/2119
fix https://github.com/FreshRSS/FreshRSS/issues/2596
fix https://github.com/FreshRSS/FreshRSS/issues/3204
fix https://github.com/FreshRSS/FreshRSS/issues/4405
fix https://github.com/FreshRSS/FreshRSS/issues/5529
fix https://github.com/FreshRSS/FreshRSS/issues/5864
fix https://github.com/FreshRSS/Extensions/issues/161

URL parameters:
* `&amp;sort=id` (current behaviour, sorting according to newest received articles)
* `&amp;sort=date` (publication date, which is not indicative of how new an article is)
* `&amp;sort=title`
* `&amp;sort=link`
* `&amp;sort=rand` (random order - which disables infinite scrolling, at least for now)

combined with `&amp;order=ASC` or `&amp;order=DESC`

![image](https://github.com/user-attachments/assets/2de5aef1-604e-4a73-a147-569f6f42a1be)

## Implementation notes

The sorting criteria by *received date* (id), which is the default, and which was the only one before this PR, is the one that has the best sorting characteristics:
* *uniqueness*: no entries have the exact same received date
* *monotonicity*: new entries always have a higher received date
* *performance*: this field is efficiently indexed in database for fast usage, including for paging (indexing could also be done to other fields, but with lower effective performance)

In contrary, sorting criteria such as by *publication date*, by *title*, or by *link* are neither unique nor monotonic. In particular, multiple articles may share the same *publication date*, and we may receive articles with a *publication date* far in the future, and then later some new articles with a *publication date* far in the past.

To understand why sorting by *publication date* is problematic, it helps to think about sorting by *title* or by *link*, as sorting by *title* and by *publication date* share more or less the same characteristics.

### Problem 1: new articles

New articles may be received in the background after what is shown on screen, and before the next user action such as *mark all as read*. Due to the lack of *monotonicity* when sorting by e.g. *publication date* or *title*, users risk marking as read a batch of articles containing some fresh articles without seeing them.

Mitigation: A parameter `idMax` tracks the maximum ID related to a batch of actions such as *mark all as read* to exclude articles received after those that are displayed.

### Problem 2: paging / pagination

When navigating articles, only a few articles are displayed, and a new "page" of articles needs to be received from the database when scrolling down or when clicking the button to show more articles. When sorting by e.g. *publication date* or *title*, it is not trivial to show the next page without re-showing some of the same articles, and without skipping any. Indeed, views are often with additional criteria such as showing only unread articles, and users may mark some articles as read while viewing them, hereby removing some articles from the previous pages. And like for *Problem 1*, new articles may have been received in the background. Consequently, it is not possible to use `OFFSET` to implement pagination (so the patches suggested by a few users were wrong due to that, in particular).

Mitigation: `idMax` is also used (just like for *Problem 1*) and a *Keyset Pagination* approach is used, combining an unstable sorting criterion such as *publication date* or *title*, together with *id* to ensure stable sorting. (So, 2 sorting criteria + 1 filter criteria)

See e.g. https://www.alwaysdeveloping.net/dailydrop/2022/07/01-keyset-pagination/

### Problem 3: performance

Sorting by anything else than *received date* (id) is doomed to be slow(er) due to the combination of 3 criteria (see *Problem 2*). An `OFFSET` approach (which is not possible anyway as explained) would be even slower. Furthermore, we have no SQL index at the moment, but they would not necessarily help much due to the multiple sorting criteria needed and involving some `OR` logic which is difficult to optimise for databases.

The nicest syntax would be using tuples and corresponding indexes, but that is poorly supported by MySQL https://bugs.mysql.com/bug.php?id=104128

Mitigation: a compatibility SQL syntax is used to implement *Keyset Pagination*

### Problem 4: user confusion

Several users have shown that they do not fully understand the difference between *received date* and *publication date*, and particularly not the pitfalls of *publication date*.

Mitigation: the menus to mark-as-read *before 1 day* and *before 1 week* are disabled when sorting by anything else than *received date*. Likewise, the separation headers *Today* and *Yesterday* and *Before yesterday* are only shown when sorting by *received date*.

Again here, to better understand why, it helps to think about sorting by *title* or by *link*, as sorting by *title* and by *publication date* share more or less the same characteristics.

* [ ] We should write a Q&amp;A and/or documentation about the problems associated to *sorting by publication date*: risks of not noticing new publication, of inadvertently marking them as read, of having some articles with a date in the future hanging at the top of the views (vice versa when sorting in ascending order), performance, etc.

### Problem 5: APIs

Sorting by anything else than *received date* breaks the guarantees needed for a successful synchronisation via API.

Mitigation: sorting by *received date* is ensured for all API calls.
</content>
</entry>
<entry>
<title>PHPStan 2.0 (#7131)</title>
<updated>2024-12-27T11:12:49+00:00</updated>
<author>
<name>Alexandre Alapetite</name>
<email>alexandre@alapetite.fr</email>
</author>
<published>2024-12-27T11:12:49+00:00</published>
<link rel='alternate' type='text/html' href='https://git.rdnlsmith.com/fresh-rss-custom/commit/?id=b1d24fbdb7d1cc948c946295035dad6df550fb7e'/>
<id>urn:sha1:b1d24fbdb7d1cc948c946295035dad6df550fb7e</id>
<content type='text'>
* PHPStan 2.0
fix https://github.com/FreshRSS/FreshRSS/issues/6989
https://github.com/phpstan/phpstan/releases/tag/2.0.0
https://github.com/phpstan/phpstan/blob/2.0.x/UPGRADING.md

* More

* More

* Done

* fix i18n CLI

* Restore a PHPStan Next test
For work towards PHPStan Level 10

* 4 more on Level 10

* fix getTagsForEntry

* API at Level 10

* More Level 10

* Finish Minz at Level 10

* Finish CLI at Level 10

* Finish Controllers at Level 10

* More Level 10

* More

* Pass bleedingEdge

* Clean PHPStan options and add TODOs

* Level 10 for main config

* More

* Consitency array vs. list

* Sanitize themes get_infos

* Simplify TagDAO-&gt;getTagsForEntries()

* Finish reportAnyTypeWideningInVarTag

* Prepare checkBenevolentUnionTypes and checkImplicitMixed

* Fixes

* Refix

* Another fix

* Casing of __METHOD__ constant</content>
</entry>
</feed>
