diff options
| author | 2023-04-07 00:13:49 +0200 | |
|---|---|---|
| committer | 2023-04-07 00:13:49 +0200 | |
| commit | 6c01e4e7d6c177ac345c826059e585bffdd1d517 (patch) | |
| tree | 45bd8ee233a306881ed81447a3f56ca224fed538 /app/Models | |
| parent | 2118448133e327294ad2b69ed8736bc29879103d (diff) | |
Use typed access to request parameters (#5267)
* Use typed access to request parameters
This was a big source of mixed datatypes in many places
* Fix notifications
* Fix bookmarkAction
Diffstat (limited to 'app/Models')
| -rw-r--r-- | app/Models/Auth.php | 4 | ||||
| -rw-r--r-- | app/Models/Context.php | 20 | ||||
| -rw-r--r-- | app/Models/SystemConfiguration.php | 2 | ||||
| -rw-r--r-- | app/Models/TagDAO.php | 4 | ||||
| -rw-r--r-- | app/Models/UserConfiguration.php | 4 |
5 files changed, 15 insertions, 19 deletions
diff --git a/app/Models/Auth.php b/app/Models/Auth.php index ccf244033..8fd06b24d 100644 --- a/app/Models/Auth.php +++ b/app/Models/Auth.php @@ -169,9 +169,9 @@ class FreshRSS_Auth { ]); $username = ''; - $token_param = Minz_Request::param('token', ''); + $token_param = Minz_Request::paramString('token'); if ($token_param != '') { - $username = trim(Minz_Request::param('user', '')); + $username = Minz_Request::paramString('user'); if ($username != '') { $conf = get_user_configuration($username); if ($conf == null) { diff --git a/app/Models/Context.php b/app/Models/Context.php index ab58adbd7..7c7af2791 100644 --- a/app/Models/Context.php +++ b/app/Models/Context.php @@ -207,12 +207,10 @@ final class FreshRSS_Context { self::$categories, 1 ); - self::_get(Minz_Request::param('get', 'a', false)); + self::_get(Minz_Request::paramString('get') ?: 'a'); - self::$state = Minz_Request::param( - 'state', self::$user_conf->default_state - ); - $state_forced_by_user = Minz_Request::param('state') !== false; + self::$state = Minz_Request::paramInt('state') ?: self::$user_conf->default_state; + $state_forced_by_user = Minz_Request::paramString('state') !== ''; if (!$state_forced_by_user && !self::isStateEnabled(FreshRSS_Entry::STATE_READ)) { if (self::$user_conf->default_view === 'adaptive' && self::$get_unread <= 0) { self::$state |= FreshRSS_Entry::STATE_READ; @@ -223,18 +221,16 @@ final class FreshRSS_Context { } } - self::$search = new FreshRSS_BooleanSearch(Minz_Request::param('search', '')); - self::$order = Minz_Request::param( - 'order', self::$user_conf->sort_order - ); - self::$number = (int)Minz_Request::param('nb', self::$user_conf->posts_per_page); + self::$search = new FreshRSS_BooleanSearch(Minz_Request::paramString('search')); + self::$order = Minz_Request::paramString('order') ?: self::$user_conf->sort_order; + self::$number = Minz_Request::paramInt('nb') ?: self::$user_conf->posts_per_page; if (self::$number > self::$user_conf->max_posts_per_rss) { self::$number = max( self::$user_conf->max_posts_per_rss, self::$user_conf->posts_per_page); } - self::$first_id = Minz_Request::param('next', ''); - self::$sinceHours = (int)Minz_Request::param('hours', 0); + self::$first_id = Minz_Request::paramString('next'); + self::$sinceHours = Minz_Request::paramInt('hours'); } /** diff --git a/app/Models/SystemConfiguration.php b/app/Models/SystemConfiguration.php index 2eed1f02a..2f68a4fe9 100644 --- a/app/Models/SystemConfiguration.php +++ b/app/Models/SystemConfiguration.php @@ -22,7 +22,7 @@ * @property-read bool $pubsubhubbub_enabled * @property-read string $salt * @property-read bool $simplepie_syslog_enabled - * @property string $unsafe_autologin_enabled + * @property bool $unsafe_autologin_enabled * @property-read array<string> $trusted_sources */ final class FreshRSS_SystemConfiguration extends Minz_Configuration { diff --git a/app/Models/TagDAO.php b/app/Models/TagDAO.php index 8dc392160..68d87efad 100644 --- a/app/Models/TagDAO.php +++ b/app/Models/TagDAO.php @@ -324,7 +324,7 @@ SQL; } } - public function tagEntry($id_tag, $id_entry, $checked = true) { + public function tagEntry(int $id_tag, string $id_entry, bool $checked = true) { if ($checked) { $sql = 'INSERT ' . $this->sqlIgnore() . ' INTO `_entrytag`(id_tag, id_entry) VALUES(?, ?)'; } else { @@ -342,7 +342,7 @@ SQL; } } - public function getTagsForEntry($id_entry) { + public function getTagsForEntry(int $id_entry) { $sql = 'SELECT t.id, t.name, et.id_entry IS NOT NULL as checked ' . 'FROM `_tag` t ' . 'LEFT OUTER JOIN `_entrytag` et ON et.id_tag = t.id AND et.id_entry=? ' diff --git a/app/Models/UserConfiguration.php b/app/Models/UserConfiguration.php index 77e1d2821..d76f5bcf5 100644 --- a/app/Models/UserConfiguration.php +++ b/app/Models/UserConfiguration.php @@ -12,7 +12,7 @@ * @property bool $bottomline_sharing * @property bool $bottomline_tags * @property string $content_width - * @property-read string $default_state + * @property-read int $default_state * @property string $default_view * @property string|bool $display_categories * @property string $show_tags @@ -47,7 +47,7 @@ * @property bool $icons_as_emojis * @property int $simplify_over_n_feeds * @property bool $show_nav_buttons - * @property string $sort_order + * @property 'ASC'|'DESC' $sort_order * @property array<string,array<string>> $sharing * @property array<string,string> $shortcuts * @property bool $sides_close_article |
