A free, self-hostable news aggregator…
Typing function checkToken (#4561)
Luc SANCHEZd9e1c1c2c3ab
diff --git a/app/Models/CategoryDAO.php b/app/Models/CategoryDAO.phpindex 20a92d52a..c855f1495 100644--- a/app/Models/CategoryDAO.php+++ b/app/Models/CategoryDAO.php@@ -265,7 +265,7 @@ SQL;return $categories;}- uasort($categories, function ($a, $b) {+ uasort($categories, static function ($a, $b) {$aPosition = $a->attributes('position');$bPosition = $b->attributes('position');if ($aPosition === $bPosition) {@@ -310,9 +310,9 @@ SQL;}/** @return array<FreshRSS_Category> */- public function listCategoriesOrderUpdate(int $defaultCacheDuration = 86400, int $limit = 0) {+ public function listCategoriesOrderUpdate(int $defaultCacheDuration = 86400, int $limit = 0): array {$sql = 'SELECT * FROM `_category` WHERE kind = :kind AND `lastUpdate` < :lu ORDER BY `lastUpdate`'- . ($limit < 1 ? '' : ' LIMIT ' . intval($limit));+ . ($limit < 1 ? '' : ' LIMIT ' . $limit);$stm = $this->pdo->prepare($sql);if ($stm &&$stm->bindValue(':kind', FreshRSS_Category::KIND_DYNAMIC_OPML, PDO::PARAM_INT) &&@@ -387,7 +387,7 @@ SQL;return $res[0]['count'];}- public function countFeed($id) {+ public function countFeed(int $id) {$sql = 'SELECT COUNT(*) AS count FROM `_feed` WHERE category=:id';$stm = $this->pdo->prepare($sql);$stm->bindParam(':id', $id, PDO::PARAM_INT);@@ -396,7 +396,7 @@ SQL;return $res[0]['count'];}- public function countNotRead($id) {+ public function countNotRead(int $id) {$sql = 'SELECT COUNT(*) AS count FROM `_entry` e INNER JOIN `_feed` f ON e.id_feed=f.id WHERE category=:id AND e.is_read=0';$stm = $this->pdo->prepare($sql);$stm->bindParam(':id', $id, PDO::PARAM_INT);@@ -409,7 +409,7 @@ SQL;* @param array<FreshRSS_Category> $categories* @param int $feed_id*/- public static function findFeed($categories, $feed_id) {+ public static function findFeed(array $categories, int $feed_id) {foreach ($categories as $category) {foreach ($category->feeds() as $feed) {if ($feed->id() === $feed_id) {@@ -422,9 +422,8 @@ SQL;/*** @param array<FreshRSS_Category> $categories- * @param int $minPriority*/- public static function CountUnreads($categories, $minPriority = 0) {+ public static function countUnread(array $categories, int $minPriority = 0): int {$n = 0;foreach ($categories as $category) {foreach ($category->feeds() as $feed) {diff --git a/app/Models/Context.php b/app/Models/Context.phpindex fed2a6767..152ecc4bf 100644--- a/app/Models/Context.php+++ b/app/Models/Context.php@@ -163,7 +163,7 @@ class FreshRSS_Context {// Update number of read / unread variables.$entryDAO = FreshRSS_Factory::createEntryDao();self::$total_starred = $entryDAO->countUnreadReadFavorites();- self::$total_unread = FreshRSS_CategoryDAO::CountUnreads(+ self::$total_unread = FreshRSS_CategoryDAO::countUnread(self::$categories, 1);diff --git a/p/api/greader.php b/p/api/greader.phpindex b08013850..afca1afaf 100644--- a/p/api/greader.php+++ b/p/api/greader.php@@ -220,7 +220,7 @@ function token($conf) {exit();}-function checkToken($conf, $token) {+function checkToken(FreshRSS_UserConfiguration $conf, string $token) {//http://code.google.com/p/google-reader-api/wiki/ActionToken$user = Minz_Session::param('currentUser', '_');if ($user !== '_' && ( //TODO: Check security consequences