diff options
| author | 2025-01-10 08:13:09 +0100 | |
|---|---|---|
| committer | 2025-01-10 08:13:09 +0100 | |
| commit | 5368f38753a3e655ed3d7d7dfc7af2cc22de7980 (patch) | |
| tree | decb975aa750660cea965bf61399df2335493b9d /app/Controllers | |
| parent | 3280ec617f8081bf0d5349e441ae564a42fdc500 (diff) | |
Reduce undeeded use of elvis operator ?: (#7204)
Diffstat (limited to 'app/Controllers')
| -rw-r--r-- | app/Controllers/authController.php | 2 | ||||
| -rw-r--r-- | app/Controllers/categoryController.php | 2 | ||||
| -rw-r--r-- | app/Controllers/entryController.php | 4 | ||||
| -rwxr-xr-x | app/Controllers/feedController.php | 10 | ||||
| -rw-r--r-- | app/Controllers/javascriptController.php | 4 | ||||
| -rw-r--r-- | app/Controllers/statsController.php | 6 | ||||
| -rw-r--r-- | app/Controllers/subscriptionController.php | 2 | ||||
| -rw-r--r-- | app/Controllers/tagController.php | 4 |
8 files changed, 15 insertions, 19 deletions
diff --git a/app/Controllers/authController.php b/app/Controllers/authController.php index 700501371..d263d6486 100644 --- a/app/Controllers/authController.php +++ b/app/Controllers/authController.php @@ -255,7 +255,7 @@ class FreshRSS_auth_Controller extends FreshRSS_ActionController { # The trailing slash is necessary so that we don’t redirect to http://. # https://bz.apache.org/bugzilla/show_bug.cgi?id=61355#c13 } else { - return _url('auth', 'logout') ?: ''; + return _url('auth', 'logout'); } } } diff --git a/app/Controllers/categoryController.php b/app/Controllers/categoryController.php index 9e27a5a4d..9fd5fd630 100644 --- a/app/Controllers/categoryController.php +++ b/app/Controllers/categoryController.php @@ -35,7 +35,7 @@ class FreshRSS_category_Controller extends FreshRSS_ActionController { $url_redirect = ['c' => 'subscription', 'a' => 'add']; $limits = FreshRSS_Context::systemConf()->limits; - $this->view->categories = $catDAO->listCategories(false) ?: []; + $this->view->categories = $catDAO->listCategories(prePopulateFeeds: false); if (count($this->view->categories) >= $limits['max_categories']) { Minz_Request::bad(_t('feedback.sub.category.over_max', $limits['max_categories']), $url_redirect); diff --git a/app/Controllers/entryController.php b/app/Controllers/entryController.php index be553267b..4c88225c0 100644 --- a/app/Controllers/entryController.php +++ b/app/Controllers/entryController.php @@ -114,7 +114,7 @@ class FreshRSS_entry_Controller extends FreshRSS_ActionController { // so the next unread tag calculation is deferred by passing next_get = 'a' instead of the current get ID. if ($next_get === 'a' && $is_read) { $tagDAO = FreshRSS_Factory::createTagDao(); - $tagsList = $tagDAO->listTags() ?: []; + $tagsList = $tagDAO->listTags(); $found_tag = false; foreach ($tagsList as $tag) { if ($found_tag) { @@ -174,7 +174,7 @@ class FreshRSS_entry_Controller extends FreshRSS_ActionController { } $entryDAO->markRead($ids, $is_read); $tagDAO = FreshRSS_Factory::createTagDao(); - $tagsForEntries = $tagDAO->getTagsForEntries($ids) ?: []; + $tagsForEntries = $tagDAO->getTagsForEntries($ids) ?? []; $tags = []; foreach ($tagsForEntries as $line) { $tags['t_' . $line['id_tag']][] = (string)$line['id_entry']; diff --git a/app/Controllers/feedController.php b/app/Controllers/feedController.php index cc321aa49..4d64b40b5 100755 --- a/app/Controllers/feedController.php +++ b/app/Controllers/feedController.php @@ -337,7 +337,7 @@ class FreshRSS_feed_Controller extends FreshRSS_ActionController { FreshRSS_View::prependTitle(_t('sub.feed.title_add') . ' · '); $catDAO = FreshRSS_Factory::createCategoryDao(); - $this->view->categories = $catDAO->listCategories(false) ?: []; + $this->view->categories = $catDAO->listCategories(prePopulateFeeds: false); $this->view->feed = new FreshRSS_Feed($url); try { // We try to get more information about the feed. @@ -423,12 +423,8 @@ class FreshRSS_feed_Controller extends FreshRSS_ActionController { } } else { $feeds = $feedDAO->listFeedsOrderUpdate(-1); - // Hydrate category for each feed to avoid that each feed has to make an SQL request - $categories = []; - foreach ($catDAO->listCategories(false, false) as $category) { - $categories[$category->id()] = $category; - } + $categories = $catDAO->listCategories(prePopulateFeeds: false, details: false); foreach ($feeds as $feed) { $category = $categories[$feed->categoryId()] ?? null; if ($category !== null) { @@ -576,7 +572,7 @@ class FreshRSS_feed_Controller extends FreshRSS_ActionController { $mark_updated_article_unread = $feed->attributeBoolean('mark_updated_article_unread') ?? FreshRSS_Context::userConf()->mark_updated_article_unread; // For this feed, check existing GUIDs already in database. - $existingHashForGuids = $entryDAO->listHashForFeedGuids($feed->id(), $newGuids) ?: []; + $existingHashForGuids = $entryDAO->listHashForFeedGuids($feed->id(), $newGuids); /** @var array<string,bool> $newGuids */ $newGuids = []; diff --git a/app/Controllers/javascriptController.php b/app/Controllers/javascriptController.php index f7002cba8..8d39a9d0c 100644 --- a/app/Controllers/javascriptController.php +++ b/app/Controllers/javascriptController.php @@ -36,9 +36,9 @@ class FreshRSS_javascript_Controller extends FreshRSS_ActionController { public function nbUnreadsPerFeedAction(): void { header('Content-Type: application/json; charset=UTF-8'); $catDAO = FreshRSS_Factory::createCategoryDao(); - $this->view->categories = $catDAO->listCategories(true, false) ?: []; + $this->view->categories = $catDAO->listCategories(prePopulateFeeds: true, details: false); $tagDAO = FreshRSS_Factory::createTagDao(); - $this->view->tags = $tagDAO->listTags(true) ?: []; + $this->view->tags = $tagDAO->listTags(precounts: true); } //For Web-form login diff --git a/app/Controllers/statsController.php b/app/Controllers/statsController.php index ee3df4ea5..7a7180176 100644 --- a/app/Controllers/statsController.php +++ b/app/Controllers/statsController.php @@ -35,7 +35,7 @@ class FreshRSS_stats_Controller extends FreshRSS_ActionController { $catDAO = FreshRSS_Factory::createCategoryDao(); $catDAO->checkDefault(); - $this->view->categories = $catDAO->listSortedCategories(false) ?: []; + $this->view->categories = $catDAO->listSortedCategories(prePopulateFeeds: false); FreshRSS_View::prependTitle(_t('admin.stats.title') . ' · '); } @@ -127,7 +127,7 @@ class FreshRSS_stats_Controller extends FreshRSS_ActionController { FreshRSS_View::appendScript(Minz_Url::display('/scripts/feed.js?' . @filemtime(PUBLIC_PATH . '/scripts/feed.js'))); $feed_dao = FreshRSS_Factory::createFeedDao(); $statsDAO = FreshRSS_Factory::createStatsDAO(); - $feeds = $statsDAO->calculateFeedLastDate() ?: []; + $feeds = $statsDAO->calculateFeedLastDate(); $idleFeeds = [ 'last_5_year' => [], 'last_3_year' => [], @@ -223,7 +223,7 @@ class FreshRSS_stats_Controller extends FreshRSS_ActionController { $id = null; } - $this->view->categories = $categoryDAO->listCategories(true) ?: []; + $this->view->categories = $categoryDAO->listCategories(prePopulateFeeds: true); $this->view->feed = $id === null ? FreshRSS_Feed::default() : ($feedDAO->searchById($id) ?? FreshRSS_Feed::default()); $this->view->days = $statsDAO->getDays(); $this->view->months = $statsDAO->getMonths(); diff --git a/app/Controllers/subscriptionController.php b/app/Controllers/subscriptionController.php index ef2bbed6e..33e4af340 100644 --- a/app/Controllers/subscriptionController.php +++ b/app/Controllers/subscriptionController.php @@ -18,7 +18,7 @@ class FreshRSS_subscription_Controller extends FreshRSS_ActionController { $catDAO = FreshRSS_Factory::createCategoryDao(); $catDAO->checkDefault(); - $this->view->categories = $catDAO->listSortedCategories(false, true) ?: []; + $this->view->categories = $catDAO->listSortedCategories(prePopulateFeeds: false, details: true); $signalError = false; foreach ($this->view->categories as $cat) { diff --git a/app/Controllers/tagController.php b/app/Controllers/tagController.php index 2bc7c0e1f..cb3f164f5 100644 --- a/app/Controllers/tagController.php +++ b/app/Controllers/tagController.php @@ -138,7 +138,7 @@ class FreshRSS_tag_Controller extends FreshRSS_ActionController { header('Cache-Control: private, no-cache, no-store, must-revalidate'); $id_entry = Minz_Request::paramString('id_entry'); $tagDAO = FreshRSS_Factory::createTagDao(); - $this->view->tagsForEntry = $tagDAO->getTagsForEntry($id_entry) ?: []; + $this->view->tagsForEntry = $tagDAO->getTagsForEntry($id_entry); } public function addAction(): void { @@ -202,6 +202,6 @@ class FreshRSS_tag_Controller extends FreshRSS_ActionController { Minz_Error::error(403); } $tagDAO = FreshRSS_Factory::createTagDao(); - $this->view->tags = $tagDAO->listTags(true) ?: []; + $this->view->tags = $tagDAO->listTags(precounts: true); } } |
