From e33ef74af9ff2f8ba1c6909b78ee07633cff240a Mon Sep 17 00:00:00 2001 From: Inverle Date: Wed, 30 Jul 2025 08:03:04 +0200 Subject: `before_login_btn` hook + system conf attributes (#7761) * `before_login_btn` hook + system conf attributes * phpstan fix * Refactoring --------- Co-authored-by: Alexandre Alapetite --- app/Models/Context.php | 8 ++++---- app/Models/UserConfiguration.php | 35 ----------------------------------- 2 files changed, 4 insertions(+), 39 deletions(-) (limited to 'app/Models') diff --git a/app/Models/Context.php b/app/Models/Context.php index 9a4e0192e..27b1c4309 100644 --- a/app/Models/Context.php +++ b/app/Models/Context.php @@ -55,10 +55,12 @@ final class FreshRSS_Context { public static bool $isCli = false; /** + * @access private * @deprecated Will be made `private`; use `FreshRSS_Context::systemConf()` instead. */ public static ?FreshRSS_SystemConfiguration $system_conf = null; /** + * @access private * @deprecated Will be made `private`; use `FreshRSS_Context::userConf()` instead. */ public static ?FreshRSS_UserConfiguration $user_conf = null; @@ -128,10 +130,8 @@ final class FreshRSS_Context { FreshRSS_Context::$search = new FreshRSS_BooleanSearch(''); //Legacy - $oldEntries = FreshRSS_Context::$user_conf->param('old_entries', 0); - $oldEntries = is_numeric($oldEntries) ? (int)$oldEntries : 0; - $keepMin = FreshRSS_Context::$user_conf->param('keep_history_default', -5); - $keepMin = is_numeric($keepMin) ? (int)$keepMin : -5; + $oldEntries = FreshRSS_Context::$user_conf->attributeInt('old_entries') ?? 0; + $keepMin = FreshRSS_Context::$user_conf->attributeInt('keep_history_default') ?? -5; if ($oldEntries > 0 || $keepMin > -5) { //Freshrss < 1.15 $archiving = FreshRSS_Context::$user_conf->archiving; $archiving['keep_max'] = false; diff --git a/app/Models/UserConfiguration.php b/app/Models/UserConfiguration.php index e53de00d3..919487bf0 100644 --- a/app/Models/UserConfiguration.php +++ b/app/Models/UserConfiguration.php @@ -105,39 +105,4 @@ final class FreshRSS_UserConfiguration extends Minz_Configuration { } return $default_user_conf; } - - /** - * @param non-empty-string $key - * @return array|null - */ - public function attributeArray(string $key): ?array { - $a = parent::param($key, null); - return is_array($a) ? $a : null; - } - - /** @param non-empty-string $key */ - public function attributeBool(string $key): ?bool { - $a = parent::param($key, null); - return is_bool($a) ? $a : null; - } - - /** @param non-empty-string $key */ - public function attributeInt(string $key): ?int { - $a = parent::param($key, null); - return is_numeric($a) ? (int)$a : null; - } - - /** @param non-empty-string $key */ - public function attributeString(string $key): ?string { - $a = parent::param($key, null); - return is_string($a) ? $a : null; - } - - /** - * @param non-empty-string $key - * @param array|mixed|null $value Value, not HTML-encoded - */ - public function _attribute(string $key, $value = null): void { - parent::_param($key, $value); - } } -- cgit v1.2.3