mirror of
https://github.com/FreshRSS/FreshRSS.git
synced 2026-04-29 02:34:05 -04:00
More robust assignment of categories to feeds (#5986)
Several minor cases, none of which should really be necessary Might help: https://github.com/FreshRSS/FreshRSS/issues/5981 https://github.com/FreshRSS/FreshRSS/issues/5982
This commit is contained in:
committed by
GitHub
parent
e968964538
commit
d65f77c081
@@ -64,7 +64,6 @@ class FreshRSS_feed_Controller extends FreshRSS_ActionController {
|
||||
if ($cat === null) {
|
||||
$catDAO->checkDefault();
|
||||
}
|
||||
$cat_id = $cat === null ? FreshRSS_CategoryDAO::DEFAULTCATEGORYID : $cat->id();
|
||||
|
||||
$feed = new FreshRSS_Feed($url); //Throws FreshRSS_BadUrl_Exception
|
||||
$title = trim($title);
|
||||
@@ -74,7 +73,11 @@ class FreshRSS_feed_Controller extends FreshRSS_ActionController {
|
||||
$feed->_kind($kind);
|
||||
$feed->_attributes($attributes);
|
||||
$feed->_httpAuth($http_auth);
|
||||
$feed->_categoryId($cat_id);
|
||||
if ($cat === null) {
|
||||
$feed->_categoryId(FreshRSS_CategoryDAO::DEFAULTCATEGORYID);
|
||||
} else {
|
||||
$feed->_category($cat);
|
||||
}
|
||||
switch ($kind) {
|
||||
case FreshRSS_Feed::KIND_RSS:
|
||||
case FreshRSS_Feed::KIND_RSS_FORCED:
|
||||
|
||||
@@ -221,7 +221,7 @@ class FreshRSS_stats_Controller extends FreshRSS_ActionController {
|
||||
$id = null;
|
||||
}
|
||||
|
||||
$this->view->categories = $categoryDAO->listCategories() ?: [];
|
||||
$this->view->categories = $categoryDAO->listCategories(true) ?: [];
|
||||
$this->view->feed = $id === null ? null : $feedDAO->searchById($id);
|
||||
$this->view->days = $statsDAO->getDays();
|
||||
$this->view->months = $statsDAO->getMonths();
|
||||
|
||||
@@ -153,6 +153,7 @@ class FreshRSS_Category extends Minz_Model {
|
||||
if ($this->feeds === null) {
|
||||
$this->feeds = [];
|
||||
}
|
||||
$feed->_category($this);
|
||||
$this->feeds[] = $feed;
|
||||
|
||||
$this->sortFeeds();
|
||||
@@ -210,7 +211,7 @@ class FreshRSS_Category extends Minz_Model {
|
||||
foreach ($dryRunCategory->feeds() as $dryRunFeed) {
|
||||
if (empty($existingFeeds[$dryRunFeed->url()])) {
|
||||
// The feed does not exist in the current category, so add that feed
|
||||
$dryRunFeed->_categoryId($this->id());
|
||||
$dryRunFeed->_category($this);
|
||||
$ok &= ($feedDAO->addFeedObject($dryRunFeed) !== false);
|
||||
} else {
|
||||
$existingFeed = $existingFeeds[$dryRunFeed->url()];
|
||||
|
||||
@@ -401,6 +401,7 @@ SQL;
|
||||
foreach ($categories as $category) {
|
||||
foreach ($category->feeds() as $feed) {
|
||||
if ($feed->id() === $feed_id) {
|
||||
$feed->_category($category); // Should already be done; just to be safe
|
||||
return $feed;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -362,7 +362,7 @@ final class FreshRSS_Context {
|
||||
|
||||
if (empty(self::$categories)) {
|
||||
$catDAO = FreshRSS_Factory::createCategoryDao();
|
||||
self::$categories = $catDAO->listCategories();
|
||||
self::$categories = $catDAO->listCategories(true);
|
||||
}
|
||||
|
||||
switch($type) {
|
||||
@@ -458,7 +458,7 @@ final class FreshRSS_Context {
|
||||
|
||||
if (empty(self::$categories)) {
|
||||
$catDAO = FreshRSS_Factory::createCategoryDao();
|
||||
self::$categories = $catDAO->listCategories();
|
||||
self::$categories = $catDAO->listCategories(true);
|
||||
}
|
||||
|
||||
if (FreshRSS_Context::userConf()->onread_jump_next && strlen($get) > 2) {
|
||||
|
||||
@@ -149,7 +149,6 @@ class FreshRSS_Import_Service {
|
||||
try {
|
||||
// Create a Feed object and add it in DB
|
||||
$feed = new FreshRSS_Feed($url);
|
||||
$feed->_categoryId($category->id());
|
||||
$category->addFeed($feed);
|
||||
$feed->_name($name);
|
||||
$feed->_website($website);
|
||||
|
||||
Reference in New Issue
Block a user