From 3b8b9eabd037130b4c05d6b615bd9ad8f02cc59f Mon Sep 17 00:00:00 2001 From: Adrien Dorsaz Date: Tue, 15 Aug 2017 10:44:54 +0200 Subject: [PATCH 1/5] commitNewEntries should ignore conflicting keys on migration from entrytmp to entry Fixes #1610 by first ignoring all entries from entrytmp which exists already inside the entry table. --- app/Models/EntryDAOPGSQL.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/Models/EntryDAOPGSQL.php b/app/Models/EntryDAOPGSQL.php index b25993c47..f70c5f65c 100644 --- a/app/Models/EntryDAOPGSQL.php +++ b/app/Models/EntryDAOPGSQL.php @@ -30,7 +30,10 @@ maxrank bigint := (SELECT MAX(id) FROM `' . $this->prefix . 'entrytmp`); rank bigint := (SELECT maxrank - COUNT(*) FROM `' . $this->prefix . 'entrytmp`); BEGIN INSERT INTO `' . $this->prefix . 'entry` (id, guid, title, author, content, link, date, `lastSeen`, hash, is_read, is_favorite, id_feed, tags) - (SELECT rank + row_number() OVER(ORDER BY date) AS id, guid, title, author, content, link, date, `lastSeen`, hash, is_read, is_favorite, id_feed, tags FROM `' . $this->prefix . 'entrytmp` ORDER BY date); + (SELECT rank + row_number() OVER(ORDER BY date) AS id, guid, title, author, content, link, date, `lastSeen`, hash, is_read, is_favorite, id_feed, tags + FROM `' . $this->prefix . 'entrytmp` AS entrytmp + WHERE NOT EXISTS (SELECT 1 FROM `' . $this->prefix . 'entry` AS entry WHERE entrytmp.id_feed = entry.id_feed AND entrytmp.guid = entry.guid) + ORDER BY date); DELETE FROM `' . $this->prefix . 'entrytmp` WHERE id <= maxrank; END $$;'; $hadTransaction = $this->bd->inTransaction(); From 074ab63bb1e59d527576cb91ed2e9f484a37b216 Mon Sep 17 00:00:00 2001 From: Adrien Dorsaz Date: Tue, 15 Aug 2017 11:39:21 +0200 Subject: [PATCH 2/5] commitNewEntries: fixup to use unique aliases --- app/Models/EntryDAOPGSQL.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/Models/EntryDAOPGSQL.php b/app/Models/EntryDAOPGSQL.php index f70c5f65c..6e6f9e658 100644 --- a/app/Models/EntryDAOPGSQL.php +++ b/app/Models/EntryDAOPGSQL.php @@ -31,8 +31,8 @@ rank bigint := (SELECT maxrank - COUNT(*) FROM `' . $this->prefix . 'entrytmp`); BEGIN INSERT INTO `' . $this->prefix . 'entry` (id, guid, title, author, content, link, date, `lastSeen`, hash, is_read, is_favorite, id_feed, tags) (SELECT rank + row_number() OVER(ORDER BY date) AS id, guid, title, author, content, link, date, `lastSeen`, hash, is_read, is_favorite, id_feed, tags - FROM `' . $this->prefix . 'entrytmp` AS entrytmp - WHERE NOT EXISTS (SELECT 1 FROM `' . $this->prefix . 'entry` AS entry WHERE entrytmp.id_feed = entry.id_feed AND entrytmp.guid = entry.guid) + FROM `' . $this->prefix . 'entrytmp` AS etmp + WHERE NOT EXISTS (SELECT 1 FROM `' . $this->prefix . 'entry` AS ereal WHERE etmp.id_feed = ereal.id_feed AND etmp.guid = ereal.guid) ORDER BY date); DELETE FROM `' . $this->prefix . 'entrytmp` WHERE id <= maxrank; END $$;'; From c23fd7782f4ea20bf7693a86c4d859a7520b01bc Mon Sep 17 00:00:00 2001 From: Adrien Dorsaz Date: Tue, 15 Aug 2017 14:06:17 +0200 Subject: [PATCH 3/5] Update changelog and add myself to contributors --- CHANGELOG.md | 1 + CREDITS.md | 1 + 2 files changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 22c11be1e..efb31a752 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ * Bug fixing * PHP 7.1 compatibility for the API [#1584](https://github.com/FreshRSS/FreshRSS/issues/1584), [#1594](https://github.com/FreshRSS/FreshRSS/pull/1594) * Fix API compatibility bug between PostgreSQL and EasyRSS [#1603](https://github.com/FreshRSS/FreshRSS/pull/1603) + * Fix PostgreSQL error when adding new entries [#1610](https://github.com/FreshRSS/FreshRSS/issues/1610), [#1613](https://github.com/FreshRSS/FreshRSS/pull/1613) * Misc. * Allow longer database usernames [#1597](https://github.com/FreshRSS/FreshRSS/issues/1597) diff --git a/CREDITS.md b/CREDITS.md index 70c7437a9..9d123f7c2 100644 --- a/CREDITS.md +++ b/CREDITS.md @@ -6,6 +6,7 @@ People are sorted by name so please keep this order. --- +* [Adrien Dorsaz](https://github.com/Trim): [contributions](https://github.com/FreshRSS/FreshRSS/commits?author=Trim), [Web](https://adorsaz.ch/) * [Alexandre Alapetite](https://github.com/Alkarex): [contributions](https://github.com/FreshRSS/FreshRSS/commits?author=Alkarex), [Web](http://alexandre.alapetite.fr/) * [Alexis Degrugillier](https://github.com/aledeg): [contributions](https://github.com/FreshRSS/FreshRSS/commits?author=aledeg) * [Alwaysin](https://github.com/Alwaysin): [contributions](https://github.com/FreshRSS/FreshRSS/commits?author=Alwaysin) From 18285d27297da3a3eb08f8fb56144d5389567ef6 Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Sat, 19 Aug 2017 13:48:47 +0200 Subject: [PATCH 4/5] Author HTML to text https://github.com/FreshRSS/FreshRSS/issues/1590#issuecomment-313914174 https://github.com/FreshRSS/FreshRSS/pull/1592#issuecomment-320290049 --- app/Models/Feed.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Models/Feed.php b/app/Models/Feed.php index 52d49db6e..4f11d32e9 100644 --- a/app/Models/Feed.php +++ b/app/Models/Feed.php @@ -339,7 +339,7 @@ class FreshRSS_Feed extends Minz_Model { $this->id(), $item->get_id(false, false), $title === null ? '' : $title, - $author === null ? '' : html_only_entity_decode($author->name), + $author === null ? '' : html_only_entity_decode(strip_tags($author->name)), $content === null ? '' : $content, $link === null ? '' : $link, $date ? $date : time() From 94f4f67f3084eb81d792d8a9b9ae147ef14726d7 Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Sat, 19 Aug 2017 13:55:04 +0200 Subject: [PATCH 5/5] Changelog 1590 https://github.com/FreshRSS/FreshRSS/issues/1590 --- CHANGELOG.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index efb31a752..3caf39d3a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,7 +9,8 @@ * Bug fixing * PHP 7.1 compatibility for the API [#1584](https://github.com/FreshRSS/FreshRSS/issues/1584), [#1594](https://github.com/FreshRSS/FreshRSS/pull/1594) * Fix API compatibility bug between PostgreSQL and EasyRSS [#1603](https://github.com/FreshRSS/FreshRSS/pull/1603) - * Fix PostgreSQL error when adding new entries [#1610](https://github.com/FreshRSS/FreshRSS/issues/1610), [#1613](https://github.com/FreshRSS/FreshRSS/pull/1613) + * Fix PostgreSQL error when adding entries with duplicated GUID [#1610](https://github.com/FreshRSS/FreshRSS/issues/1610) + * Fix for RSS feeds containing HTML in author field [#1590](https://github.com/FreshRSS/FreshRSS/issues/1590) * Misc. * Allow longer database usernames [#1597](https://github.com/FreshRSS/FreshRSS/issues/1597)