summaryrefslogtreecommitdiff
path: root/app/Controllers/importExportController.php
diff options
context:
space:
mode:
authorGravatar Marien Fressinaud <dev@marienfressinaud.fr> 2014-10-29 11:47:51 +0100
committerGravatar Marien Fressinaud <dev@marienfressinaud.fr> 2014-10-29 11:47:51 +0100
commitd20b5a127fe95f91b55f3ae9391365c67f96c4cc (patch)
treef978c2f29dc934c375b9d228a6fe702d0ced9d67 /app/Controllers/importExportController.php
parentfb3cda8ac9f7c8895ed33d7db432a92b063a7198 (diff)
Fix limit in import Json files
See https://github.com/marienfressinaud/FreshRSS/issues/680
Diffstat (limited to 'app/Controllers/importExportController.php')
-rw-r--r--app/Controllers/importExportController.php28
1 files changed, 25 insertions, 3 deletions
diff --git a/app/Controllers/importExportController.php b/app/Controllers/importExportController.php
index 514077bbd..8028af8ed 100644
--- a/app/Controllers/importExportController.php
+++ b/app/Controllers/importExportController.php
@@ -327,12 +327,34 @@ class FreshRSS_importExport_Controller extends Minz_ActionController {
$error = false;
$article_to_feed = array();
+ $nb_feeds = count($this->feedDAO->listFeeds());
+ $limits = Minz_Configuration::limits();
+
// First, we check feeds of articles are in DB (and add them if needed).
foreach ($article_object['items'] as $item) {
- $feed = $this->addFeedJson($item['origin'], $google_compliant);
+ $key = $google_compliant ? 'htmlUrl' : 'feedUrl';
+ $feed = new FreshRSS_Feed($item['origin'][$key]);
+ $feed = $this->feedDAO->searchByUrl($feed->url());
+
if (is_null($feed)) {
- $error = true;
- } else {
+ // Feed does not exist in DB,we should to try to add it.
+ if ($nb_feeds >= $limits['max_feeds']) {
+ // Oops, no more place!
+ Minz_Log::warning(_t('sub.feeds.over_max', $limits['max_feeds']));
+ } else {
+ $feed = $this->addFeedJson($item['origin'], $google_compliant);
+ }
+
+ if (is_null($feed)) {
+ // Still null? It means something went wrong.
+ $error = true;
+ } else {
+ // Nice! Increase the counter.
+ $nb_feeds += 1;
+ }
+ }
+
+ if (!is_null($feed)) {
$article_to_feed[$item['id']] = $feed->id();
}
}