aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Alexandre Alapetite <alexandre@alapetite.fr> 2018-05-28 23:33:48 +0200
committerGravatar GitHub <noreply@github.com> 2018-05-28 23:33:48 +0200
commit1801f44bfca5ecc0f5709f03c9ee3434b78a9bf9 (patch)
tree6c4366f3fa409089fcba93447bb3dbaec712bb2c
parent58fb9ea5b32040fdb64ece910f0ede1aafb97329 (diff)
Fix import: invalid variable scope (#1901)
* Fix import: invalid variable scope https://github.com/FreshRSS/FreshRSS/issues/1890 https://github.com/FreshRSS/FreshRSS/pull/1315 * Changelog 1890 https://github.com/FreshRSS/FreshRSS/issues/1890 https://github.com/FreshRSS/FreshRSS/pull/1901
-rw-r--r--CHANGELOG.md1
-rw-r--r--app/Controllers/importExportController.php21
2 files changed, 14 insertions, 8 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 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.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);