A free, self-hostable news aggregator…
Fix import: invalid variable scope (#1901)
Alexandre Alapetite1801f44bfca5
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 80e2f05eb..88cdce03e 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -24,6 +24,7 @@* Fix Docker bug affecting Apache `CustomLog` (unwanted local copy of access logs), `ErrorLog`, `Listen` (IPv6 bug) [#1873](https://github.com/FreshRSS/FreshRSS/pull/1873)* Fix muted feeds that were not actually muted [#1844](https://github.com/FreshRSS/FreshRSS/issues/1844)* Fix null exception in shares, showing only the first article [#1824](https://github.com/FreshRSS/FreshRSS/issues/1824)+ * Fix error during import[#1890](https://github.com/FreshRSS/FreshRSS/issues/1890)* Fix errors in case of empty/wrong username when updating user settings [#1857](https://github.com/FreshRSS/FreshRSS/pull/1857)* Fixes in subscription menu [#1858](https://github.com/FreshRSS/FreshRSS/pull/1858)* Fix allowing Unix sockets for MySQL and PostgreSQL [#1888](https://github.com/FreshRSS/FreshRSS/issues/1888)diff --git a/app/Controllers/importExportController.php b/app/Controllers/importExportController.phpindex 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);