summaryrefslogtreecommitdiff
path: root/app/Controllers/importExportController.php
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 /app/Controllers/importExportController.php
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
Diffstat (limited to 'app/Controllers/importExportController.php')
-rw-r--r--app/Controllers/importExportController.php21
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);