From 0904f159b3b2e016647dd7211a4caa11d058ec11 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20Steinh=C3=B6fer?= Date: Mon, 29 Apr 2019 09:59:18 +0200 Subject: [PATCH] Configurable amount of feeds that gets refreshed. Enhanced actualizeFeed with a maxFeeds-Parameter, so that a user can control how many feeds he wants to refresh instead of being force to choose between "10 or all". --- app/Controllers/feedController.php | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/app/Controllers/feedController.php b/app/Controllers/feedController.php index 0aed9b0a1..862bb10fb 100755 --- a/app/Controllers/feedController.php +++ b/app/Controllers/feedController.php @@ -243,7 +243,7 @@ class FreshRSS_feed_Controller extends Minz_ActionController { } } - public static function actualizeFeed($feed_id, $feed_url, $force, $simplePiePush = null, $isNewFeed = false, $noCommit = false) { + public static function actualizeFeed($feed_id, $feed_url, $force, $simplePiePush = null, $isNewFeed = false, $noCommit = false, $maxFeeds = 10) { @set_time_limit(300); $feedDAO = FreshRSS_Factory::createFeedDao(); @@ -262,6 +262,11 @@ class FreshRSS_feed_Controller extends Minz_ActionController { $feeds = $feedDAO->listFeedsOrderUpdate(-1); } + // Set maxFeeds to a minimum of 10 + if (!is_int($maxFeeds) || $maxFeeds < 10) { + $maxFeeds = 10; + } + // Calculate date of oldest entries we accept in DB. $nb_month_old = max(FreshRSS_Context::$user_conf->old_entries, 1); $date_min = time() - (3600 * 24 * 30 * $nb_month_old); @@ -459,9 +464,9 @@ class FreshRSS_feed_Controller extends Minz_ActionController { $updated_feeds++; unset($feed); - // No more than 10 feeds unless $force is true to avoid overloading + // No more than $maxFeeds feeds unless $force is true to avoid overloading // the server. - if ($updated_feeds >= 10 && !$force) { + if ($updated_feeds >= $maxFeeds && !$force) { break; } } @@ -497,6 +502,7 @@ class FreshRSS_feed_Controller extends Minz_ActionController { $id = Minz_Request::param('id'); $url = Minz_Request::param('url'); $force = Minz_Request::param('force'); + $maxFeeds = (int)Minz_Request::param('maxFeeds'); $noCommit = Minz_Request::fetchPOST('noCommit', 0) == 1; if ($id == -1 && !$noCommit) { //Special request only to commit & refresh DB cache @@ -511,7 +517,7 @@ class FreshRSS_feed_Controller extends Minz_ActionController { $databaseDAO = FreshRSS_Factory::createDatabaseDAO(); $databaseDAO->minorDbMaintenance(); } else { - list($updated_feeds, $feed, $nb_new_articles) = self::actualizeFeed($id, $url, $force, null, false, $noCommit); + list($updated_feeds, $feed, $nb_new_articles) = self::actualizeFeed($id, $url, $force, null, false, $noCommit, $maxFeeds); } if (Minz_Request::param('ajax')) {