From 28db5dd2858002b376c920ec1d1aaad4ef254d54 Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Sat, 23 Sep 2017 12:32:35 +0200 Subject: Fix SQL constraint insert into entrytmp table https://github.com/FreshRSS/FreshRSS/issues/1614 --- app/Controllers/feedController.php | 7 ++++++- app/Controllers/importExportController.php | 7 ++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/app/Controllers/feedController.php b/app/Controllers/feedController.php index 66b1167a8..45cba9e98 100755 --- a/app/Controllers/feedController.php +++ b/app/Controllers/feedController.php @@ -320,11 +320,16 @@ class FreshRSS_feed_Controller extends Minz_ActionController { } // For this feed, check existing GUIDs already in database. $existingHashForGuids = $entryDAO->listHashForFeedGuids($feed->id(), $newGuids); - unset($newGuids); + $newGuids = array(); $oldGuids = array(); // Add entries in database if possible. foreach ($entries as $entry) { + if (isset($newGuids[$entry->guid()])) { + continue; //Skip subsequent articles with same GUID + } + $newGuids[$entry->guid()] = true; + $entry_date = $entry->date(true); if (isset($existingHashForGuids[$entry->guid()])) { $existingHash = $existingHashForGuids[$entry->guid()]; diff --git a/app/Controllers/importExportController.php b/app/Controllers/importExportController.php index a69490e70..a76dd9a2b 100644 --- a/app/Controllers/importExportController.php +++ b/app/Controllers/importExportController.php @@ -426,7 +426,7 @@ class FreshRSS_importExport_Controller extends Minz_ActionController { } // For this feed, check existing GUIDs already in database. $existingHashForGuids = $this->entryDAO->listHashForFeedGuids($feed->id(), $newGuids); - unset($newGuids); + $newGuids = array(); // Then, articles are imported. $this->entryDAO->beginTransaction(); @@ -455,6 +455,11 @@ class FreshRSS_importExport_Controller extends Minz_ActionController { $entry->_id(min(time(), $entry->date(true)) . uSecString()); $entry->_tags($tags); + if (isset($newGuids[$entry->guid()])) { + continue; //Skip subsequent articles with same GUID + } + $newGuids[$entry->guid()] = true; + $entry = Minz_ExtensionManager::callHook('entry_before_insert', $entry); if ($entry == null) { // An extension has returned a null value, there is nothing to insert. -- cgit v1.2.3 From 8cbb052758b02f266f42b6ba953c32419c0bcd4d Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Sat, 23 Sep 2017 12:34:31 +0200 Subject: Changelog 1614 https://github.com/FreshRSS/FreshRSS/issues/1614 --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index de4645622..6d16ba447 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,7 +16,7 @@ * Fix month abbreviations [#1560](https://github.com/FreshRSS/FreshRSS/issues/1560) * Bug fixing * Fix API compatibility bug between PostgreSQL and EasyRSS [#1603](https://github.com/FreshRSS/FreshRSS/pull/1603) - * Fix PostgreSQL error when adding entries with duplicated GUID [#1610](https://github.com/FreshRSS/FreshRSS/issues/1610) + * Fix PostgreSQL error when adding entries with duplicated GUID [#1610](https://github.com/FreshRSS/FreshRSS/issues/1610), [#1614](https://github.com/FreshRSS/FreshRSS/issues/1614) * Fix for RSS feeds containing HTML in author field [#1590](https://github.com/FreshRSS/FreshRSS/issues/1590) * Misc. * Travis continuous integration [#1619](https://github.com/FreshRSS/FreshRSS/pull/1619) -- cgit v1.2.3