owncloud-archive / news

:newspaper: News app for ownCloud
GNU Affero General Public License v3.0
290 stars 106 forks source link

Old feed items can't be marked as read #981

Closed ServiusHack closed 8 years ago

ServiusHack commented 8 years ago

I recently noticed that I can't mark old items of news feeds as read. The UI updates correctly but after reloading the page the item is shown as unread. The following describes what I found out and believe to be the root cause.

The request is correctly processed and this query is sent to the database:

UPDATE `*PREFIX*news_items`
                SET `status` = `status` & ?,
                    `last_modified` = ?
                WHERE `fingerprint` = ?
                    AND `feed_id` IN (
                        SELECT `f`.`id` FROM `*PREFIX*news_feeds` AS `f`
                            WHERE `f`.`user_id` = ?
                    )

The following parameters are used:

array (size=4)
  0 => int -3
  1 => int 1461415202
  2 => null
  3 => string 'my_username' (length=11)

Here you can see the problem. The parameter for WHERE fingerprint = ? is null thus the above query will never match any row (= null is always false).

Fingerprints were introduced with fae882f834409e18174e05d19deea39a3bf01e7b. Commit 65d28653ae1a1d2a7680ccfa694dbb7e2d4d750f started using them to mark items as read. Still, even in the recent version I can't find migration code which adds fingerprints for old items. They will always be null and can never be marked as read.

System Information

BernhardPosselt commented 8 years ago

Migration code is here: https://github.com/owncloud/news/blob/master/upgrade/upgrade.php#L50

Search indices were introduced in 6.1.2 so that code should have been run. Will check later ;)

BernhardPosselt commented 8 years ago

Can you set your database version to 6.1.2. and check if the db migration fixes it?

UPDATE oc_appconfig SET configvalue = '6.1.2' WHERE appid = 'news' and configkey = 'installed_version';
ServiusHack commented 8 years ago

The db migration fixed it. Running SELECT count(*) FROM oc_news_items WHERE fingerprint IS NULL returns 0 and marking items as read persists upon page reload. Thank you for your help and this great app!