A free, self-hostable news aggregator…
fixed bug when adding a category and feed at the same time (#1731)
Kevin Papst62e9db55b210
diff --git a/app/Controllers/feedController.php b/app/Controllers/feedController.phpindex 883f7af05..fff20f798 100755--- a/app/Controllers/feedController.php+++ b/app/Controllers/feedController.php@@ -26,6 +26,18 @@ class FreshRSS_feed_Controller extends Minz_ActionController {}}+ /**+ * @param $url+ * @param string $title+ * @param int $cat_id+ * @param string $new_cat_name+ * @param string $http_auth+ * @return FreshRSS_Feed|the+ * @throws FreshRSS_AlreadySubscribed_Exception+ * @throws FreshRSS_FeedNotAdded_Exception+ * @throws FreshRSS_Feed_Exception+ * @throws Minz_FileNotExistException+ */public static function addFeed($url, $title = '', $cat_id = 0, $new_cat_name = '', $http_auth = '') {FreshRSS_UserDAO::touch();@set_time_limit(300);@@ -33,12 +45,13 @@ class FreshRSS_feed_Controller extends Minz_ActionController {$catDAO = new FreshRSS_CategoryDAO();$cat = null;+ if ($new_cat_name != '') {+ $new_cat_id = $catDAO->addCategory(array('name' => $new_cat_name));+ $cat_id = $new_cat_id > 0 ? $new_cat_id : $cat_id;+ }if ($cat_id > 0) {$cat = $catDAO->searchById($cat_id);}- if ($cat == null && $new_cat_name != '') {- $cat = $catDAO->addCategory(array('name' => $new_cat_name));- }if ($cat == null) {$catDAO->checkDefault();}@@ -54,7 +67,7 @@ class FreshRSS_feed_Controller extends Minz_ActionController {throw new FreshRSS_AlreadySubscribed_Exception($url, $feed->name());}- // Call the extension hook+ /** @var FreshRSS_Feed $feed */$feed = Minz_ExtensionManager::callHook('feed_before_insert', $feed);if ($feed === null) {throw new FreshRSS_FeedNotAdded_Exception($url, $feed->name());@@ -136,7 +149,7 @@ class FreshRSS_feed_Controller extends Minz_ActionController {// User want to create a new category, new_category parameter// must exist$new_cat = Minz_Request::param('new_category');- $new_cat_name = isset($new_cat['name']) ? $new_cat['name'] : '';+ $new_cat_name = isset($new_cat['name']) ? trim($new_cat['name']) : '';}// HTTP information are useful if feed is protected behind a