Bug 437190

Summary: Wrong order for entries with the same date
Product: [Applications] akregator Reporter: Daniel Roschka <danielroschka>
Component: generalAssignee: kdepim bugs <kdepim-bugs>
Status: REPORTED ---    
Severity: minor    
Priority: NOR    
Version First Reported In: unspecified   
Target Milestone: ---   
Platform: Debian unstable   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:
Attachments: Screenshot showing the wrong order in Akregator

Description Daniel Roschka 2021-05-16 08:18:13 UTC
Created attachment 138475 [details]
Screenshot showing the wrong order in Akregator

SUMMARY

When fetching a feed which contains multiple entries with the same date and which contains new entries on consecutive fetches (but still with the same date), the entries are ordered incorrectly in Akregator when ordering by date.

STEPS TO REPRODUCE
1. Create a file (e.g. /tmp/wrong_date.xml) with the following content:

<?xml version="1.0" encoding="utf-8"?>
<feed xml:lang="en" xmlns="http://www.w3.org/2005/Atom"><title>Wrong order for same dates</title><link href="https://example.tld" rel="alternate"></link><id>https://example.tld</id><updated>2021-05-16T00:00:00+02:00</updated><entry><title>Entry 1 from first fetch</title><link href="https://example.tld/1/" rel="alternate"></link><published>2021-05-16T00:00:00+02:00</published><updated>2021-05-16T00:00:00+02:00</updated><id>11</id><summary type="html">-</summary></entry><entry><title>Entry 2 from first fetch</title><link href="https://example.tld/2/" rel="alternate"></link><published>2021-05-16T00:00:00+02:00</published><updated>2021-05-16T00:00:00+02:00</updated><id>12</id><summary type="html">-</summary></entry><entry><title>Entry 3 from first fetch</title><link href="https://example.tld/3/" rel="alternate"></link><published>2021-05-16T00:00:00+02:00</published><updated>2021-05-16T00:00:00+02:00</updated><id>13</id><summary type="html">-</summary></entry><entry><title>Entry 4 from first fetch</title><link href="https://example.tld/4/" rel="alternate"></link><published>2021-05-16T00:00:00+02:00</published><updated>2021-05-16T00:00:00+02:00</updated><id>14</id><summary type="html">-</summary></entry></feed>

2. Subscribe to a new feed in Akregator, using the stored file as source (file:///tmp/wrong_date.xml)
3. Fetch the feed in Akregator.
4. Replace the content of the file with the following content:

<?xml version="1.0" encoding="utf-8"?>
<feed xml:lang="en" xmlns="http://www.w3.org/2005/Atom"><title>Wrong order for same dates</title><link href="https://example.tld" rel="alternate"></link><id>https://example.tld</id><updated>2021-05-16T00:00:00+02:00</updated><entry><title>Entry 1 from second fetch</title><link href="https://example.tld/1/" rel="alternate"></link><published>2021-05-16T00:00:00+02:00</published><updated>2021-05-16T00:00:00+02:00</updated><id>21</id><summary type="html">-</summary></entry><entry><title>Entry 2 from second fetch</title><link href="https://example.tld/2/" rel="alternate"></link><published>2021-05-16T00:00:00+02:00</published><updated>2021-05-16T00:00:00+02:00</updated><id>22</id><summary type="html">-</summary></entry><entry><title>Entry 3 from second fetch</title><link href="https://example.tld/3/" rel="alternate"></link><published>2021-05-16T00:00:00+02:00</published><updated>2021-05-16T00:00:00+02:00</updated><id>23</id><summary type="html">-</summary></entry><entry><title>Entry 4 from second fetch</title><link href="https://example.tld/4/" rel="alternate"></link><published>2021-05-16T00:00:00+02:00</published><updated>2021-05-16T00:00:00+02:00</updated><id>24</id><summary type="html">-</summary></entry></feed>

5. Fetch the feed in Akregator again.
6. Replace the content of the file with the following content once again:

<?xml version="1.0" encoding="utf-8"?>
<feed xml:lang="en" xmlns="http://www.w3.org/2005/Atom"><title>Wrong order for same dates</title><link href="https://example.tld" rel="alternate"></link><id>https://example.tld</id><updated>2021-05-16T00:00:00+02:00</updated><entry><title>Entry 1 from third fetch</title><link href="https://example.tld/1/" rel="alternate"></link><published>2021-05-16T00:00:00+02:00</published><updated>2021-05-16T00:00:00+02:00</updated><id>31</id><summary type="html">-</summary></entry><entry><title>Entry 2 from third fetch</title><link href="https://example.tld/2/" rel="alternate"></link><published>2021-05-16T00:00:00+02:00</published><updated>2021-05-16T00:00:00+02:00</updated><id>32</id><summary type="html">-</summary></entry><entry><title>Entry 3 from third fetch</title><link href="https://example.tld/3/" rel="alternate"></link><published>2021-05-16T00:00:00+02:00</published><updated>2021-05-16T00:00:00+02:00</updated><id>33</id><summary type="html">-</summary></entry><entry><title>Entry 4 from third fetch</title><link href="https://example.tld/4/" rel="alternate"></link><published>2021-05-16T00:00:00+02:00</published><updated>2021-05-16T00:00:00+02:00</updated><id>34</id><summary type="html">-</summary></entry></feed>

7. Fetch the feed in Akregator again.

OBSERVED RESULT

When sorting by date, the entries are sorted with the following order:

Entry 1 from first fetch
Entry 1 from second fetch
Entry 1 from third fetch
Entry 2 from first fetch
Entry 2 from second fetch
Entry 2 from third fetch
Entry 3 from first fetch
Entry 3 from second fetch
Entry 3 from third fetch

Please note that the titles of the entries are not the reason for this sort order. This happens with arbitrary titles as well.

I've also attached a screenshot showing how this looks in Akregator.

EXPECTED RESULT

I'd expect entries with the same date from different fetches to be sorted by the time of fetching:

Entry 1 from third fetch
Entry 2 from third fetch
Entry 3 from third fetch
Entry 1 from second fetch
Entry 2 from second fetch
Entry 3 from second fetch
Entry 1 from first fetch
Entry 2 from first fetch
Entry 3 from first fetch


SOFTWARE/OS VERSIONS
Linux/KDE Plasma: 
Akregator version: 5.15.3
KDE Plasma Version: 5.20.5
KDE Frameworks Version: 5.78.0
Qt Version: 5.15.2

ADDITIONAL INFORMATION

There is also another unrelated bug shown in the screenshot. Akregator sometimes seems to have some kind of off-by-one error when the publishing date of an entry is exactly at midnight.