From 1c7c1016f4a5147003ed1c438b8a386a63a53cab Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Mon, 4 Sep 2023 10:09:37 +0200 Subject: Fix JSON export/import (#5626) * Fix import with empty content fix https://github.com/FreshRSS/FreshRSS/issues/5622 Cherry picks on https://github.com/FreshRSS/FreshRSS/pull/5584 * Fix export of tags / labels Article-defined tags were wrongly exported as user-defined labels. * Fix export of tags / labels Article-defined tags were wrongly exported as user-defined labels. * Fix bug with many labels * Better typing * Comments --- app/Controllers/importExportController.php | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'app/Controllers/importExportController.php') diff --git a/app/Controllers/importExportController.php b/app/Controllers/importExportController.php index 9c18b608f..807a355db 100644 --- a/app/Controllers/importExportController.php +++ b/app/Controllers/importExportController.php @@ -309,7 +309,7 @@ class FreshRSS_importExport_Controller extends FreshRSS_ActionController { $limits = FreshRSS_Context::$system_conf->limits; // First, we check feeds of articles are in DB (and add them if needed). - foreach ($items as $item) { + foreach ($items as &$item) { if (!isset($item['guid']) && isset($item['id'])) { $item['guid'] = $item['id']; } @@ -382,7 +382,7 @@ class FreshRSS_importExport_Controller extends FreshRSS_ActionController { // Then, articles are imported. $newGuids = []; $this->entryDAO->beginTransaction(); - foreach ($items as $item) { + foreach ($items as &$item) { if (empty($item['guid']) || empty($article_to_feed[$item['guid']])) { // Related feed does not exist for this entry, do nothing. continue; @@ -427,14 +427,17 @@ class FreshRSS_importExport_Controller extends FreshRSS_ActionController { } else { $url = ''; } + if (!is_string($url)) { + $url = ''; + } $title = empty($item['title']) ? $url : $item['title']; - if (!empty($item['content']['content'])) { + if (isset($item['content']['content']) && is_string($item['content']['content'])) { $content = $item['content']['content']; - } elseif (!empty($item['summary']['content'])) { + } elseif (isset($item['summary']['content']) && is_string($item['summary']['content'])) { $content = $item['summary']['content']; - } elseif (!empty($item['content'])) { + } elseif (isset($item['content']) && is_string($item['content'])) { $content = $item['content']; //FeedBin } else { $content = ''; -- cgit v1.2.3