aboutsummaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
Diffstat (limited to 'app')
-rw-r--r--app/FreshRSS.php24
-rw-r--r--app/Models/Entry.php5
-rw-r--r--app/Models/EntryDAO.php13
3 files changed, 27 insertions, 15 deletions
diff --git a/app/FreshRSS.php b/app/FreshRSS.php
index e374fa827..76ced841c 100644
--- a/app/FreshRSS.php
+++ b/app/FreshRSS.php
@@ -18,7 +18,7 @@ class FreshRSS extends Minz_FrontController {
* - Init notifications
* - Enable user extensions (need all the other initializations)
*/
- public function init() {
+ public function init(): void {
if (!isset($_SESSION)) {
Minz_Session::init('FreshRSS');
}
@@ -71,10 +71,10 @@ class FreshRSS extends Minz_FrontController {
Minz_ExtensionManager::callHook('freshrss_init');
}
- private static function initAuth() {
+ private static function initAuth(): void {
FreshRSS_Auth::init();
if (Minz_Request::isPost()) {
- if (!(FreshRSS_Auth::isCsrfOk() ||
+ if (FreshRSS_Context::$system_conf == null || !(FreshRSS_Auth::isCsrfOk() ||
(Minz_Request::controllerName() === 'auth' && Minz_Request::actionName() === 'login') ||
(Minz_Request::controllerName() === 'user' && Minz_Request::actionName() === 'create' && !FreshRSS_Auth::hasAccess('admin')) ||
(Minz_Request::controllerName() === 'feed' && Minz_Request::actionName() === 'actualize'
@@ -92,7 +92,7 @@ class FreshRSS extends Minz_FrontController {
}
}
- private static function initI18n() {
+ private static function initI18n(): void {
$userLanguage = isset(FreshRSS_Context::$user_conf) ? FreshRSS_Context::$user_conf->language : null;
$systemLanguage = isset(FreshRSS_Context::$system_conf) ? FreshRSS_Context::$system_conf->language : null;
$language = Minz_Translate::getLanguage($userLanguage, Minz_Request::getPreferredLanguages(), $systemLanguage);
@@ -107,12 +107,15 @@ class FreshRSS extends Minz_FrontController {
date_default_timezone_set($timezone);
}
- private static function getThemeFileUrl($theme_id, $filename) {
+ private static function getThemeFileUrl(string $theme_id, string $filename): string {
$filetime = @filemtime(PUBLIC_PATH . '/themes/' . $theme_id . '/' . $filename);
return '/themes/' . $theme_id . '/' . $filename . '?' . $filetime;
}
- public static function loadStylesAndScripts() {
+ public static function loadStylesAndScripts(): void {
+ if (FreshRSS_Context::$user_conf == null) {
+ return;
+ }
$theme = FreshRSS_Themes::load(FreshRSS_Context::$user_conf->theme);
if ($theme) {
foreach(array_reverse($theme['files']) as $file) {
@@ -146,22 +149,23 @@ class FreshRSS extends Minz_FrontController {
FreshRSS_View::prependScript(Minz_Url::display('/scripts/main.js?' . @filemtime(PUBLIC_PATH . '/scripts/main.js')));
}
- private static function loadNotifications() {
+ private static function loadNotifications(): void {
$notif = Minz_Request::getNotification();
if ($notif) {
FreshRSS_View::_param('notification', $notif);
}
}
- public static function preLayout() {
+ public static function preLayout(): void {
header("X-Content-Type-Options: nosniff");
FreshRSS_Share::load(join_path(APP_PATH, 'shares.php'));
self::loadStylesAndScripts();
}
- private static function checkEmailValidated() {
- $email_not_verified = FreshRSS_Auth::hasAccess() && FreshRSS_Context::$user_conf->email_validation_token !== '';
+ private static function checkEmailValidated(): void {
+ $email_not_verified = FreshRSS_Auth::hasAccess() &&
+ FreshRSS_Context::$user_conf !== null && FreshRSS_Context::$user_conf->email_validation_token !== '';
$action_is_allowed = (
Minz_Request::is('user', 'validateEmail') ||
Minz_Request::is('user', 'sendValidationEmail') ||
diff --git a/app/Models/Entry.php b/app/Models/Entry.php
index 16de8beb6..81ece1ce4 100644
--- a/app/Models/Entry.php
+++ b/app/Models/Entry.php
@@ -17,10 +17,14 @@ class FreshRSS_Entry extends Minz_Model {
*/
private $guid;
+ /** @var string */
private $title;
private $authors;
+ /** @var string */
private $content;
+ /** @var string */
private $link;
+ /** @var int */
private $date;
private $date_added = 0; //In microseconds
/**
@@ -298,6 +302,7 @@ HTML;
public function link(): string {
return $this->link;
}
+ /** @return string|int */
public function date(bool $raw = false) {
if ($raw) {
return $this->date;
diff --git a/app/Models/EntryDAO.php b/app/Models/EntryDAO.php
index cda51e5b4..3b7c1ac3f 100644
--- a/app/Models/EntryDAO.php
+++ b/app/Models/EntryDAO.php
@@ -1165,10 +1165,12 @@ SQL;
}
}
- public function listByIds($ids, $order = 'DESC') {
+ /** @param array<string> $ids */
+ public function listByIds(array $ids, string $order = 'DESC') {
if (count($ids) < 1) {
- yield false;
- } elseif (count($ids) > FreshRSS_DatabaseDAO::MAX_VARIABLE_NUMBER) {
+ return;
+ }
+ if (count($ids) > FreshRSS_DatabaseDAO::MAX_VARIABLE_NUMBER) {
// Split a query with too many variables parameters
$idsChunks = array_chunk($ids, FreshRSS_DatabaseDAO::MAX_VARIABLE_NUMBER);
foreach ($idsChunks as $idsChunk) {
@@ -1195,15 +1197,16 @@ SQL;
/**
* For API
+ * @return array<string>
*/
public function listIdsWhere($type = 'a', $id = '', $state = FreshRSS_Entry::STATE_ALL,
- $order = 'DESC', $limit = 1, $firstId = '', $filters = null) {
+ $order = 'DESC', $limit = 1, $firstId = '', $filters = null): array {
list($values, $sql) = $this->sqlListWhere($type, $id, $state, $order, $limit, $firstId, $filters);
$stm = $this->pdo->prepare($sql);
$stm->execute($values);
- return $stm->fetchAll(PDO::FETCH_COLUMN, 0);
+ return $stm->fetchAll(PDO::FETCH_COLUMN, 0) ?: [];
}
public function listHashForFeedGuids($id_feed, $guids) {