diff options
| author | 2018-06-03 13:35:38 +0200 | |
|---|---|---|
| committer | 2018-06-03 13:35:38 +0200 | |
| commit | c0122003fe3031926546012b86a38b5187082613 (patch) | |
| tree | 5502841327e7775f280fbd12732b4e8b8b7be6ff /app/Controllers/importExportController.php | |
| parent | 029f4107123f6c318584bf9a43da7118c318657f (diff) | |
| parent | be778c6bc2d8075e5a923153183b47507a2a71e3 (diff) | |
Merge pull request #1902 from FreshRSS/dev1.11.0
FreshRSS 1.11.0
Diffstat (limited to 'app/Controllers/importExportController.php')
| -rw-r--r-- | app/Controllers/importExportController.php | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/app/Controllers/importExportController.php b/app/Controllers/importExportController.php index a76dd9a2b..0fb5ba651 100644 --- a/app/Controllers/importExportController.php +++ b/app/Controllers/importExportController.php @@ -390,6 +390,7 @@ class FreshRSS_importExport_Controller extends Minz_ActionController { $article_to_feed = array(); $nb_feeds = count($this->feedDAO->listFeeds()); + $newFeedGuids = array(); $limits = FreshRSS_Context::$system_conf->limits; // First, we check feeds of articles are in DB (and add them if needed). @@ -417,21 +418,25 @@ class FreshRSS_importExport_Controller extends Minz_ActionController { if ($feed != null) { $article_to_feed[$item['id']] = $feed->id(); + if (!isset($newFeedGuids['f_' . $feed->id()])) { + $newFeedGuids['f_' . $feed->id()] = array(); + } + $newFeedGuids['f_' . $feed->id()][] = safe_ascii($item['id']); } } - $newGuids = array(); - foreach ($article_object['items'] as $item) { - $newGuids[] = safe_ascii($item['id']); + // For each feed, check existing GUIDs already in database. + $existingHashForGuids = array(); + foreach ($newFeedGuids as $feedId => $newGuids) { + $existingHashForGuids[$feedId] = $this->entryDAO->listHashForFeedGuids(substr($feedId, 2), $newGuids); } - // For this feed, check existing GUIDs already in database. - $existingHashForGuids = $this->entryDAO->listHashForFeedGuids($feed->id(), $newGuids); - $newGuids = array(); + unset($newFeedGuids); // Then, articles are imported. + $newGuids = array(); $this->entryDAO->beginTransaction(); foreach ($article_object['items'] as $item) { - if (!isset($article_to_feed[$item['id']])) { + if (empty($article_to_feed[$item['id']])) { // Related feed does not exist for this entry, do nothing. continue; } @@ -468,7 +473,7 @@ class FreshRSS_importExport_Controller extends Minz_ActionController { $values = $entry->toArray(); $ok = false; - if (isset($existingHashForGuids[$entry->guid()])) { + if (isset($existingHashForGuids['f_' . $feed_id][$entry->guid()])) { $ok = $this->entryDAO->updateEntry($values); } else { $ok = $this->entryDAO->addEntry($values); |
