diff options
| author | 2017-12-17 16:36:48 +0100 | |
|---|---|---|
| committer | 2017-12-17 16:36:48 +0100 | |
| commit | 62e9db55b21034f92b0f4603512c3e788e0351f1 (patch) | |
| tree | d753f005504349d527e9ad406e134b0f25f51748 /app/Controllers/feedController.php | |
| parent | 429b290411871a65723053bfae8d928d3a3a75b8 (diff) | |
fixed bug when adding a category and feed at the same time (#1731)
fixed bug when adding a category and feed at the same time
Diffstat (limited to 'app/Controllers/feedController.php')
| -rwxr-xr-x | app/Controllers/feedController.php | 23 |
1 files changed, 18 insertions, 5 deletions
diff --git a/app/Controllers/feedController.php b/app/Controllers/feedController.php index 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 |
