diff options
| author | 2016-10-15 14:26:09 +0200 | |
|---|---|---|
| committer | 2016-10-15 14:26:09 +0200 | |
| commit | 98a038926232511fdabc1cfaf5dfb220508047aa (patch) | |
| tree | e11a903ab68ec672b8a934e843ad924b6bcec628 | |
| parent | f0c5943250c5a9582ebb752b92ca639cad9d283e (diff) | |
| parent | 021c377f80223868c7423feb3256135938849cab (diff) | |
Merge pull request #1315 from Alkarex/import_duplicates
Fix bug JSON import duplicates
| -rw-r--r-- | CHANGELOG.md | 1 | ||||
| -rw-r--r-- | app/Controllers/importExportController.php | 14 |
2 files changed, 14 insertions, 1 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index fbc23e1b9..7d4e36c7f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,6 +22,7 @@ * Correction of bugs related CSRF tokens introduced in version 1.5.0 [#1253](https://github.com/FreshRSS/FreshRSS/issues/1253), [44f22ab](https://github.com/FreshRSS/FreshRSS/pull/1261/commits/d9bf9b2c6f0b2cc9dec3b638841b7e3040dcf46f) * Fix bug in Global view introduced in version 1.5.0 [#1269](https://github.com/FreshRSS/FreshRSS/pull/1269) * Fix sharing bug [#1289](https://github.com/FreshRSS/FreshRSS/issues/1289) + * Fix bug during import of favourites [#1315](https://github.com/FreshRSS/FreshRSS/pull/1315), [#1312](https://github.com/FreshRSS/FreshRSS/issues/1312) * Fix bug not respecting language option for new users [#1273](https://github.com/FreshRSS/FreshRSS/issues/1273) * Bug in example of URL for FreshRS RSS output with token [#1274](https://github.com/FreshRSS/FreshRSS/issues/1274) * SimplePie diff --git a/app/Controllers/importExportController.php b/app/Controllers/importExportController.php index 9dfc479f0..d36c57deb 100644 --- a/app/Controllers/importExportController.php +++ b/app/Controllers/importExportController.php @@ -360,6 +360,14 @@ class FreshRSS_importExport_Controller extends Minz_ActionController { } } + $newGuids = array(); + foreach ($article_object['items'] as $item) { + $newGuids[] = $item['id']; + } + // For this feed, check existing GUIDs already in database. + $existingHashForGuids = $this->entryDAO->listHashForFeedGuids($feed->id(), $newGuids); + unset($newGuids); + // Then, articles are imported. $this->entryDAO->beginTransaction(); foreach ($article_object['items'] as $item) { @@ -395,7 +403,11 @@ class FreshRSS_importExport_Controller extends Minz_ActionController { } $values = $entry->toArray(); - $id = $this->entryDAO->addEntry($values); + if (isset($existingHashForGuids[$entry->guid()])) { + $id = $this->entryDAO->updateEntry($values); + } else { + $id = $this->entryDAO->addEntry($values); + } if (!$error && ($id === false)) { $error = true; |
