Merge pull request #1638 from Alkarex/tmp_unique_guids

Fix SQL constraint insert into entrytmp table
pull/1645/head
Alexandre Alapetite 7 years ago committed by GitHub
commit a38bd3da8a
  1. 2
      CHANGELOG.md
  2. 7
      app/Controllers/feedController.php
  3. 7
      app/Controllers/importExportController.php

@ -16,7 +16,7 @@
* Fix month abbreviations [#1560](https://github.com/FreshRSS/FreshRSS/issues/1560) * Fix month abbreviations [#1560](https://github.com/FreshRSS/FreshRSS/issues/1560)
* Bug fixing * Bug fixing
* Fix API compatibility bug between PostgreSQL and EasyRSS [#1603](https://github.com/FreshRSS/FreshRSS/pull/1603) * 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) * Fix for RSS feeds containing HTML in author field [#1590](https://github.com/FreshRSS/FreshRSS/issues/1590)
* Fix logout issue in global view due to CSRF [#1591](https://github.com/FreshRSS/FreshRSS/issues/1591) * Fix logout issue in global view due to CSRF [#1591](https://github.com/FreshRSS/FreshRSS/issues/1591)
* Misc. * Misc.

@ -320,11 +320,16 @@ class FreshRSS_feed_Controller extends Minz_ActionController {
} }
// For this feed, check existing GUIDs already in database. // For this feed, check existing GUIDs already in database.
$existingHashForGuids = $entryDAO->listHashForFeedGuids($feed->id(), $newGuids); $existingHashForGuids = $entryDAO->listHashForFeedGuids($feed->id(), $newGuids);
unset($newGuids); $newGuids = array();
$oldGuids = array(); $oldGuids = array();
// Add entries in database if possible. // Add entries in database if possible.
foreach ($entries as $entry) { 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); $entry_date = $entry->date(true);
if (isset($existingHashForGuids[$entry->guid()])) { if (isset($existingHashForGuids[$entry->guid()])) {
$existingHash = $existingHashForGuids[$entry->guid()]; $existingHash = $existingHashForGuids[$entry->guid()];

@ -426,7 +426,7 @@ class FreshRSS_importExport_Controller extends Minz_ActionController {
} }
// For this feed, check existing GUIDs already in database. // For this feed, check existing GUIDs already in database.
$existingHashForGuids = $this->entryDAO->listHashForFeedGuids($feed->id(), $newGuids); $existingHashForGuids = $this->entryDAO->listHashForFeedGuids($feed->id(), $newGuids);
unset($newGuids); $newGuids = array();
// Then, articles are imported. // Then, articles are imported.
$this->entryDAO->beginTransaction(); $this->entryDAO->beginTransaction();
@ -455,6 +455,11 @@ class FreshRSS_importExport_Controller extends Minz_ActionController {
$entry->_id(min(time(), $entry->date(true)) . uSecString()); $entry->_id(min(time(), $entry->date(true)) . uSecString());
$entry->_tags($tags); $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); $entry = Minz_ExtensionManager::callHook('entry_before_insert', $entry);
if ($entry == null) { if ($entry == null) {
// An extension has returned a null value, there is nothing to insert. // An extension has returned a null value, there is nothing to insert.

Loading…
Cancel
Save