aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Alexandre Alapetite <alexandre@alapetite.fr> 2025-01-10 08:13:09 +0100
committerGravatar GitHub <noreply@github.com> 2025-01-10 08:13:09 +0100
commit5368f38753a3e655ed3d7d7dfc7af2cc22de7980 (patch)
treedecb975aa750660cea965bf61399df2335493b9d
parent3280ec617f8081bf0d5349e441ae564a42fdc500 (diff)
Reduce undeeded use of elvis operator ?: (#7204)
-rw-r--r--app/Controllers/authController.php2
-rw-r--r--app/Controllers/categoryController.php2
-rw-r--r--app/Controllers/entryController.php4
-rwxr-xr-xapp/Controllers/feedController.php10
-rw-r--r--app/Controllers/javascriptController.php4
-rw-r--r--app/Controllers/statsController.php6
-rw-r--r--app/Controllers/subscriptionController.php2
-rw-r--r--app/Controllers/tagController.php4
-rw-r--r--app/Models/CategoryDAO.php3
-rw-r--r--app/Models/Context.php8
-rw-r--r--app/Models/DatabaseDAOSQLite.php5
-rw-r--r--app/Models/Entry.php3
-rw-r--r--app/Models/EntryDAO.php8
-rw-r--r--app/Models/EntryDAOSQLite.php3
-rw-r--r--app/Models/Search.php8
-rw-r--r--app/Models/TagDAO.php40
-rw-r--r--app/Models/View.php2
-rw-r--r--app/Services/ExportService.php6
-rw-r--r--app/Services/ImportService.php2
-rw-r--r--cli/i18n/I18nFile.php5
-rw-r--r--lib/Minz/Url.php4
-rw-r--r--p/api/fever.php2
-rw-r--r--p/api/greader.php12
23 files changed, 71 insertions, 74 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);
}
}
diff --git a/app/Models/CategoryDAO.php b/app/Models/CategoryDAO.php
index a41d23e10..5d191f321 100644
--- a/app/Models/CategoryDAO.php
+++ b/app/Models/CategoryDAO.php
@@ -289,8 +289,7 @@ SQL;
. 'ORDER BY c.name, f.name';
$stm = $this->pdo->prepare($sql);
$values = [ ':priority' => FreshRSS_Feed::PRIORITY_CATEGORY ];
- if ($stm !== false && $stm->execute($values)) {
- $res = $stm->fetchAll(PDO::FETCH_ASSOC) ?: [];
+ if ($stm !== false && $stm->execute($values) && ($res = $stm->fetchAll(PDO::FETCH_ASSOC)) !== false) {
/** @var list<array{c_name:string,c_id:int,c_kind:int,c_last_update:int,c_error:int|bool,c_attributes?:string,
* id?:int,name?:string,url?:string,kind?:int,category?:int,website?:string,priority?:int,error?:int|bool,attributes?:string,cache_nbEntries?:int,cache_nbUnreads?:int,ttl?:int}> $res */
return self::daoToCategoriesPrepopulated($res);
diff --git a/app/Models/Context.php b/app/Models/Context.php
index 0c8161c8b..8bee4630a 100644
--- a/app/Models/Context.php
+++ b/app/Models/Context.php
@@ -177,7 +177,7 @@ final class FreshRSS_Context {
public static function categories(): array {
if (empty(self::$categories)) {
$catDAO = FreshRSS_Factory::createCategoryDao();
- self::$categories = $catDAO->listSortedCategories(true, false);
+ self::$categories = $catDAO->listSortedCategories(prePopulateFeeds: true, details: false);
}
return self::$categories;
}
@@ -191,7 +191,7 @@ final class FreshRSS_Context {
public static function labels(bool $precounts = false): array {
if (empty(self::$tags) || $precounts) {
$tagDAO = FreshRSS_Factory::createTagDao();
- self::$tags = $tagDAO->listTags($precounts) ?: [];
+ self::$tags = $tagDAO->listTags($precounts);
}
return self::$tags;
}
@@ -400,7 +400,7 @@ final class FreshRSS_Context {
if (empty(self::$categories)) {
$catDAO = FreshRSS_Factory::createCategoryDao();
$details = $type === 'f'; // Load additional feed details in the case of feed view
- self::$categories = $catDAO->listCategories(true, $details);
+ self::$categories = $catDAO->listCategories(prePopulateFeeds: true, details: $details);
}
switch ($type) {
@@ -505,7 +505,7 @@ final class FreshRSS_Context {
if (empty(self::$categories)) {
$catDAO = FreshRSS_Factory::createCategoryDao();
- self::$categories = $catDAO->listCategories(true);
+ self::$categories = $catDAO->listCategories(prePopulateFeeds: true);
}
if (FreshRSS_Context::userConf()->onread_jump_next && strlen($get) > 2) {
diff --git a/app/Models/DatabaseDAOSQLite.php b/app/Models/DatabaseDAOSQLite.php
index f59f6c9ae..c425135b5 100644
--- a/app/Models/DatabaseDAOSQLite.php
+++ b/app/Models/DatabaseDAOSQLite.php
@@ -37,10 +37,9 @@ class FreshRSS_DatabaseDAOSQLite extends FreshRSS_DatabaseDAO {
public function getSchema(string $table): array {
$sql = 'PRAGMA table_info(' . $table . ')';
$stm = $this->pdo->query($sql);
- if ($stm !== false) {
- $res = $stm->fetchAll(PDO::FETCH_ASSOC);
+ if ($stm !== false && ($res = $stm->fetchAll(PDO::FETCH_ASSOC)) !== false) {
/** @var list<array{name:string,type:string,notnull:bool,dflt_value:string|int|bool|null}> $res */
- return $this->listDaoToSchema($res ?: []);
+ return $this->listDaoToSchema($res);
}
return [];
}
diff --git a/app/Models/Entry.php b/app/Models/Entry.php
index 0919489fc..f86948122 100644
--- a/app/Models/Entry.php
+++ b/app/Models/Entry.php
@@ -879,9 +879,8 @@ HTML;
if ($nodes != false) {
$filter_xpath = $path_entries_filter === '' ? '' : (new Gt\CssXPath\Translator($path_entries_filter, 'descendant-or-self::'))->asXPath();
foreach ($nodes as $node) {
- if ($filter_xpath !== '') {
+ if ($filter_xpath !== '' && ($filterednodes = $xpath->query($filter_xpath, $node)) !== false) {
// Remove unwanted elements once before sanitizing, for CSS selectors to also match original content
- $filterednodes = $xpath->query($filter_xpath, $node) ?: [];
foreach ($filterednodes as $filterednode) {
if ($filterednode === $node) {
continue 2;
diff --git a/app/Models/EntryDAO.php b/app/Models/EntryDAO.php
index c169e0e24..af229df54 100644
--- a/app/Models/EntryDAO.php
+++ b/app/Models/EntryDAO.php
@@ -1427,9 +1427,9 @@ SQL;
/**
* @param array<string> $guids
- * @return array<string,string>|false
+ * @return array<string,string> guid => hash
*/
- public function listHashForFeedGuids(int $id_feed, array $guids): array|false {
+ public function listHashForFeedGuids(int $id_feed, array $guids): array {
$result = [];
if (count($guids) < 1) {
return $result;
@@ -1437,7 +1437,7 @@ SQL;
// Split a query with too many variables parameters
$guidsChunks = array_chunk($guids, FreshRSS_DatabaseDAO::MAX_VARIABLE_NUMBER);
foreach ($guidsChunks as $guidsChunk) {
- $result += $this->listHashForFeedGuids($id_feed, $guidsChunk) ?: [];
+ $result += $this->listHashForFeedGuids($id_feed, $guidsChunk);
}
return $result;
}
@@ -1457,7 +1457,7 @@ SQL;
$info = $stm === false ? $this->pdo->errorInfo() : $stm->errorInfo();
Minz_Log::error('SQL error ' . __METHOD__ . json_encode($info)
. ' while querying feed ' . $id_feed);
- return false;
+ return [];
}
}
diff --git a/app/Models/EntryDAOSQLite.php b/app/Models/EntryDAOSQLite.php
index e4cb9727e..99e216e53 100644
--- a/app/Models/EntryDAOSQLite.php
+++ b/app/Models/EntryDAOSQLite.php
@@ -57,8 +57,7 @@ class FreshRSS_EntryDAOSQLite extends FreshRSS_EntryDAO {
/** @param array{0:string,1:int,2:string} $errorInfo */
#[\Override]
protected function autoUpdateDb(array $errorInfo): bool {
- if (($tableInfo = $this->pdo->query("PRAGMA table_info('entry')")) !== false) {
- $columns = $tableInfo->fetchAll(PDO::FETCH_COLUMN, 1) ?: [];
+ if (($tableInfo = $this->pdo->query("PRAGMA table_info('entry')")) !== false && ($columns = $tableInfo->fetchAll(PDO::FETCH_COLUMN, 1)) !== false) {
foreach (['attributes'] as $column) {
if (!in_array($column, $columns, true)) {
return $this->addColumn($column);
diff --git a/app/Models/Search.php b/app/Models/Search.php
index 3eb8b422a..5b88b1f3b 100644
--- a/app/Models/Search.php
+++ b/app/Models/Search.php
@@ -506,7 +506,7 @@ class FreshRSS_Search implements \Stringable {
$input = str_replace($matches[0], '', $input);
}
if (preg_match_all('/\\bintitle:(?P<search>[^\s"]*)/', $input, $matches)) {
- $this->intitle = array_merge($this->intitle ?: [], $matches['search']);
+ $this->intitle = array_merge($this->intitle ?? [], $matches['search']);
$input = str_replace($matches[0], '', $input);
}
$this->intitle = self::removeEmptyValues($this->intitle);
@@ -526,7 +526,7 @@ class FreshRSS_Search implements \Stringable {
$input = str_replace($matches[0], '', $input);
}
if (preg_match_all('/(?<=[\\s(]|^)[!-]intitle:(?P<search>[^\s"]*)/', $input, $matches)) {
- $this->not_intitle = array_merge($this->not_intitle ?: [], $matches['search']);
+ $this->not_intitle = array_merge($this->not_intitle ?? [], $matches['search']);
$input = str_replace($matches[0], '', $input);
}
$this->not_intitle = self::removeEmptyValues($this->not_intitle);
@@ -551,7 +551,7 @@ class FreshRSS_Search implements \Stringable {
$input = str_replace($matches[0], '', $input);
}
if (preg_match_all('/\\bauthor:(?P<search>[^\s"]*)/', $input, $matches)) {
- $this->author = array_merge($this->author ?: [], $matches['search']);
+ $this->author = array_merge($this->author ?? [], $matches['search']);
$input = str_replace($matches[0], '', $input);
}
$this->author = self::removeEmptyValues($this->author);
@@ -571,7 +571,7 @@ class FreshRSS_Search implements \Stringable {
$input = str_replace($matches[0], '', $input);
}
if (preg_match_all('/(?<=[\\s(]|^)[!-]author:(?P<search>[^\s"]*)/', $input, $matches)) {
- $this->not_author = array_merge($this->not_author ?: [], $matches['search']);
+ $this->not_author = array_merge($this->not_author ?? [], $matches['search']);
$input = str_replace($matches[0], '', $input);
}
$this->not_author = self::removeEmptyValues($this->not_author);
diff --git a/app/Models/TagDAO.php b/app/Models/TagDAO.php
index 2f12c96d4..c2a653238 100644
--- a/app/Models/TagDAO.php
+++ b/app/Models/TagDAO.php
@@ -182,8 +182,8 @@ SQL;
return $res === null ? null : (current(self::daoToTags($res)) ?: null);
}
- /** @return array<int,FreshRSS_Tag>|false where the key is the label ID */
- public function listTags(bool $precounts = false): array|false {
+ /** @return array<int,FreshRSS_Tag> where the key is the label ID */
+ public function listTags(bool $precounts = false): array {
if ($precounts) {
$sql = <<<'SQL'
SELECT t.id, t.name, count(e.id) AS unreads
@@ -198,13 +198,12 @@ SQL;
}
$stm = $this->pdo->query($sql);
- if ($stm !== false) {
- $res = $stm->fetchAll(PDO::FETCH_ASSOC) ?: [];
+ if ($stm !== false && ($res = $stm->fetchAll(PDO::FETCH_ASSOC)) !== false) {
return self::daoToTags($res);
} else {
$info = $this->pdo->errorInfo();
Minz_Log::error('SQL error ' . __METHOD__ . json_encode($info));
- return false;
+ return [];
}
}
@@ -319,9 +318,9 @@ SQL;
}
/**
- * @return array<int,array{id:int,name:string,checked:bool}>|false
+ * @return list<array{id:int,name:string,checked:bool}>
*/
- public function getTagsForEntry(string $id_entry): array|false {
+ public function getTagsForEntry(string $id_entry): array {
$sql = <<<'SQL'
SELECT t.id, t.name, et.id_entry IS NOT NULL as checked
FROM `_tag` t
@@ -332,24 +331,27 @@ SQL;
$stm = $this->pdo->prepare($sql);
$values = [$id_entry];
- if ($stm !== false && $stm->execute($values)) {
- $lines = $stm->fetchAll(PDO::FETCH_ASSOC);
- for ($i = count($lines) - 1; $i >= 0; $i--) {
- $lines[$i]['id'] = (int)($lines[$i]['id']);
- $lines[$i]['checked'] = !empty($lines[$i]['checked']);
+ if ($stm !== false && $stm->execute($values) && ($lines = $stm->fetchAll(PDO::FETCH_ASSOC)) !== false) {
+ $result = [];
+ foreach ($lines as $line) {
+ $result[] = [
+ 'id' => (int)($line['id']),
+ 'name' => $line['name'],
+ 'checked' => !empty($line['checked']),
+ ];
}
- return $lines;
+ return $result;
}
$info = $stm === false ? $this->pdo->errorInfo() : $stm->errorInfo();
Minz_Log::error('SQL error ' . __METHOD__ . json_encode($info));
- return false;
+ return [];
}
/**
* @param list<FreshRSS_Entry|numeric-string> $entries
- * @return list<array{id_entry:int|numeric-string,id_tag:int,name:string}>|false
+ * @return list<array{id_entry:int|numeric-string,id_tag:int,name:string}>|null
*/
- public function getTagsForEntries(array $entries): array|false {
+ public function getTagsForEntries(array $entries): array|null {
$sql = <<<'SQL'
SELECT et.id_entry, et.id_tag, t.name
FROM `_tag` t
@@ -364,7 +366,7 @@ SQL;
foreach ($idsChunks as $idsChunk) {
$valuesChunk = $this->getTagsForEntries($idsChunk);
if (!is_array($valuesChunk)) {
- return false;
+ return null;
}
$values = array_merge($values, $valuesChunk);
}
@@ -384,7 +386,7 @@ SQL;
}
$info = $stm === false ? $this->pdo->errorInfo() : $stm->errorInfo();
Minz_Log::error('SQL error ' . __METHOD__ . json_encode($info));
- return false;
+ return null;
}
/**
@@ -395,7 +397,7 @@ SQL;
*/
public function getEntryIdsTagNames(array $entries): array {
$result = [];
- foreach ($this->getTagsForEntries($entries) ?: [] as $line) {
+ foreach ($this->getTagsForEntries($entries) ?? [] as $line) {
$entryId = 'e_' . $line['id_entry'];
$tagName = $line['name'];
if (empty($result[$entryId])) {
diff --git a/app/Models/View.php b/app/Models/View.php
index 943c50055..dd616b888 100644
--- a/app/Models/View.php
+++ b/app/Models/View.php
@@ -24,7 +24,7 @@ class FreshRSS_View extends Minz_View {
public int $nbUnreadTags;
/** @var array<int,FreshRSS_Tag> where the key is the label ID */
public array $tags;
- /** @var array<int,array{id:int,name:string,checked:bool}> */
+ /** @var list<array{id:int,name:string,checked:bool}> */
public array $tagsForEntry;
/** @var array<string,array<string>> */
public array $tagsForEntries;
diff --git a/app/Services/ExportService.php b/app/Services/ExportService.php
index e9acda614..69f0b3d2b 100644
--- a/app/Services/ExportService.php
+++ b/app/Services/ExportService.php
@@ -40,7 +40,7 @@ class FreshRSS_Export_Service {
public function generateOpml(): array {
$view = new FreshRSS_View();
$day = date('Y-m-d');
- $view->categories = $this->category_dao->listCategories(true, true) ?: [];
+ $view->categories = $this->category_dao->listCategories(prePopulateFeeds: true, details: true);
$view->excludeMutedFeeds = false;
return [
@@ -64,7 +64,7 @@ class FreshRSS_Export_Service {
*/
public function generateStarredEntries(string $type): array {
$view = new FreshRSS_View();
- $view->categories = $this->category_dao->listCategories(true) ?: [];
+ $view->categories = $this->category_dao->listCategories(prePopulateFeeds: true);
$day = date('Y-m-d');
$view->list_title = _t('sub.import_export.starred_list');
@@ -89,7 +89,7 @@ class FreshRSS_Export_Service {
*/
public function generateFeedEntries(int $feed_id, int $max_number_entries): ?array {
$view = new FreshRSS_View();
- $view->categories = $this->category_dao->listCategories(true) ?: [];
+ $view->categories = $this->category_dao->listCategories(prePopulateFeeds: true);
$feed = FreshRSS_Category::findFeed($view->categories, $feed_id);
if ($feed === null) {
diff --git a/app/Services/ImportService.php b/app/Services/ImportService.php
index 142a0ce09..00bb89229 100644
--- a/app/Services/ImportService.php
+++ b/app/Services/ImportService.php
@@ -58,7 +58,7 @@ class FreshRSS_Import_Service {
// Get the categories by names so we can use this array to retrieve
// existing categories later.
- $categories = $this->catDAO->listCategories(false) ?: [];
+ $categories = $this->catDAO->listCategories(prePopulateFeeds: false);
$categories_by_names = [];
foreach ($categories as $category) {
$categories_by_names[$category->name()] = $category;
diff --git a/cli/i18n/I18nFile.php b/cli/i18n/I18nFile.php
index 6771dfbff..48b9710bf 100644
--- a/cli/i18n/I18nFile.php
+++ b/cli/i18n/I18nFile.php
@@ -65,7 +65,10 @@ class I18nFile {
* @return array<string,string|array<string,mixed>>
*/
private function process(string $filename): array {
- $fileContent = file_get_contents($filename) ?: [];
+ $fileContent = file_get_contents($filename);
+ if (!is_string($fileContent)) {
+ return [];
+ }
$content = str_replace('<?php', '', $fileContent);
$content = preg_replace([
diff --git a/lib/Minz/Url.php b/lib/Minz/Url.php
index f388054fc..f849ec6b6 100644
--- a/lib/Minz/Url.php
+++ b/lib/Minz/Url.php
@@ -170,11 +170,11 @@ class Minz_Url {
}
}
-function _url(string $controller, string $action, int|string ...$args): string|false {
+function _url(string $controller, string $action, int|string ...$args): string {
$nb_args = count($args);
if ($nb_args % 2 !== 0) {
- return false;
+ return '';
}
$params = [];
diff --git a/p/api/fever.php b/p/api/fever.php
index b3a2a074c..2ef3e4f9a 100644
--- a/p/api/fever.php
+++ b/p/api/fever.php
@@ -335,7 +335,7 @@ final class FeverAPI
$groups = [];
$categoryDAO = FreshRSS_Factory::createCategoryDao();
- $categories = $categoryDAO->listCategories(false, false) ?: [];
+ $categories = $categoryDAO->listCategories(prePopulateFeeds: false, details: false);
foreach ($categories as $category) {
$groups[] = [
diff --git a/p/api/greader.php b/p/api/greader.php
index bbe533c86..4c9b183e3 100644
--- a/p/api/greader.php
+++ b/p/api/greader.php
@@ -280,7 +280,7 @@ final class GReaderAPI {
// ['id' => 'user/-/state/com.google/broadcast', 'sortid' => '2']
];
$categoryDAO = FreshRSS_Factory::createCategoryDao();
- $categories = $categoryDAO->listCategories(prePopulateFeeds: false, details: false) ?: [];
+ $categories = $categoryDAO->listCategories(prePopulateFeeds: false, details: false);
foreach ($categories as $cat) {
$tags[] = [
'id' => 'user/-/label/' . htmlspecialchars_decode($cat->name(), ENT_QUOTES),
@@ -290,7 +290,7 @@ final class GReaderAPI {
}
$tagDAO = FreshRSS_Factory::createTagDao();
- $labels = $tagDAO->listTags(true) ?: [];
+ $labels = $tagDAO->listTags(precounts: true);
foreach ($labels as $label) {
$tags[] = [
'id' => 'user/-/label/' . htmlspecialchars_decode($label->name(), ENT_QUOTES),
@@ -338,7 +338,7 @@ final class GReaderAPI {
$subscriptions = [];
$categoryDAO = FreshRSS_Factory::createCategoryDao();
- foreach ($categoryDAO->listCategories(true, true) ?: [] as $cat) {
+ foreach ($categoryDAO->listCategories(prePopulateFeeds: true, details: true) as $cat) {
foreach ($cat->feeds() as $feed) {
$subscriptions[] = [
'id' => 'feed/' . $feed->id(),
@@ -493,7 +493,7 @@ final class GReaderAPI {
$feedDAO = FreshRSS_Factory::createFeedDao();
$feedsNewestItemUsec = $feedDAO->listFeedsNewestItemUsec();
$unreadcounts = [];
- foreach ($categoryDAO->listCategories(true, true) ?: [] as $cat) {
+ foreach ($categoryDAO->listCategories(prePopulateFeeds: true, details: true) as $cat) {
$catLastUpdate = 0;
foreach ($cat->feeds() as $feed) {
$lastUpdate = $feedsNewestItemUsec['f_' . $feed->id()] ?? 0;
@@ -519,7 +519,7 @@ final class GReaderAPI {
$tagDAO = FreshRSS_Factory::createTagDao();
$tagsNewestItemUsec = $tagDAO->listTagsNewestItemUsec();
- foreach ($tagDAO->listTags(true) ?: [] as $label) {
+ foreach ($tagDAO->listTags(precounts: true) as $label) {
$lastUpdate = $tagsNewestItemUsec['t_' . $label->id()] ?? 0;
$unreadcounts[] = [
'id' => 'user/-/label/' . htmlspecialchars_decode($label->name(), ENT_QUOTES),
@@ -550,7 +550,7 @@ final class GReaderAPI {
return [];
}
$catDAO = FreshRSS_Factory::createCategoryDao();
- $categories = $catDAO->listCategories(true) ?: [];
+ $categories = $catDAO->listCategories(prePopulateFeeds: true);
$tagDAO = FreshRSS_Factory::createTagDao();
$entryIdsTagNames = $tagDAO->getEntryIdsTagNames($entries);