diff options
| author | 2023-10-30 20:40:13 +0100 | |
|---|---|---|
| committer | 2023-10-30 20:40:13 +0100 | |
| commit | 4a02352ccc1b313ce967415c6ac10a32aba1893a (patch) | |
| tree | 36bec23832a05acb930a5386d7eefb3535323a38 | |
| parent | d50bb386e7bc9ee9595338119edc4951d10c526a (diff) | |
applies several small optimizations (#5511)
declare(strict_types=1);
Co-authored-by: Luc <sanchezluc+freshrss@gmail.com>
| -rw-r--r-- | app/Exceptions/ContextException.php | 1 | ||||
| -rw-r--r-- | app/Exceptions/DAOException.php | 2 | ||||
| -rw-r--r-- | app/Exceptions/EntriesGetterException.php | 2 | ||||
| -rw-r--r-- | app/Exceptions/FeedException.php | 2 | ||||
| -rw-r--r-- | app/Exceptions/ZipMissingException.php | 2 | ||||
| -rw-r--r-- | app/Models/ActionController.php | 2 | ||||
| -rw-r--r-- | app/Models/Log.php | 2 | ||||
| -rw-r--r-- | app/Models/SystemConfiguration.php | 3 | ||||
| -rw-r--r-- | app/Models/TagDAOPGSQL.php | 2 | ||||
| -rw-r--r-- | app/Models/UserConfiguration.php | 3 | ||||
| -rw-r--r-- | app/Models/ViewJavascript.php | 2 | ||||
| -rw-r--r-- | app/Models/ViewStats.php | 2 | ||||
| -rw-r--r-- | app/Utils/feverUtil.php | 10 | ||||
| -rw-r--r-- | app/install.php | 4 | ||||
| -rw-r--r-- | app/shares.php | 2 |
15 files changed, 37 insertions, 4 deletions
diff --git a/app/Exceptions/ContextException.php b/app/Exceptions/ContextException.php index 00934cbfd..d2d29abc0 100644 --- a/app/Exceptions/ContextException.php +++ b/app/Exceptions/ContextException.php @@ -1,5 +1,6 @@ <?php +declare(strict_types=1); /** * An exception raised when a context is invalid */ diff --git a/app/Exceptions/DAOException.php b/app/Exceptions/DAOException.php index 14bee3403..71ed371f8 100644 --- a/app/Exceptions/DAOException.php +++ b/app/Exceptions/DAOException.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + class FreshRSS_DAO_Exception extends Exception { } diff --git a/app/Exceptions/EntriesGetterException.php b/app/Exceptions/EntriesGetterException.php index 3b76195ee..d145a0ed5 100644 --- a/app/Exceptions/EntriesGetterException.php +++ b/app/Exceptions/EntriesGetterException.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + class FreshRSS_EntriesGetter_Exception extends Exception { } diff --git a/app/Exceptions/FeedException.php b/app/Exceptions/FeedException.php index abfcbce79..49843f3ed 100644 --- a/app/Exceptions/FeedException.php +++ b/app/Exceptions/FeedException.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + class FreshRSS_Feed_Exception extends Exception { } diff --git a/app/Exceptions/ZipMissingException.php b/app/Exceptions/ZipMissingException.php index 864cc3991..5b4791b1b 100644 --- a/app/Exceptions/ZipMissingException.php +++ b/app/Exceptions/ZipMissingException.php @@ -1,4 +1,6 @@ <?php +declare(strict_types=1); + class FreshRSS_ZipMissing_Exception extends Exception { } diff --git a/app/Models/ActionController.php b/app/Models/ActionController.php index 69548feb3..1a46cff36 100644 --- a/app/Models/ActionController.php +++ b/app/Models/ActionController.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + class FreshRSS_ActionController extends Minz_ActionController { /** diff --git a/app/Models/Log.php b/app/Models/Log.php index 72208513d..96714d1c7 100644 --- a/app/Models/Log.php +++ b/app/Models/Log.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + class FreshRSS_Log extends Minz_Model { /** @var string */ private $date; diff --git a/app/Models/SystemConfiguration.php b/app/Models/SystemConfiguration.php index 6cb3569f1..bf5bed0d7 100644 --- a/app/Models/SystemConfiguration.php +++ b/app/Models/SystemConfiguration.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + /** * @property bool $allow_anonymous * @property bool $allow_anonymous_refresh @@ -27,6 +29,7 @@ */ final class FreshRSS_SystemConfiguration extends Minz_Configuration { + /** @throws Minz_ConfigurationNamespaceException */ public static function init(string $config_filename, ?string $default_filename = null): FreshRSS_SystemConfiguration { parent::register('system', $config_filename, $default_filename); return parent::get('system'); diff --git a/app/Models/TagDAOPGSQL.php b/app/Models/TagDAOPGSQL.php index cfc14a77f..1b8bb7784 100644 --- a/app/Models/TagDAOPGSQL.php +++ b/app/Models/TagDAOPGSQL.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + class FreshRSS_TagDAOPGSQL extends FreshRSS_TagDAO { public function sqlIgnore(): string { diff --git a/app/Models/UserConfiguration.php b/app/Models/UserConfiguration.php index 30095af34..47d0fac49 100644 --- a/app/Models/UserConfiguration.php +++ b/app/Models/UserConfiguration.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + /** * @property string $apiPasswordHash * @property array<string,mixed> $archiving @@ -71,6 +73,7 @@ */ final class FreshRSS_UserConfiguration extends Minz_Configuration { + /** @throws Minz_ConfigurationNamespaceException */ public static function init(string $config_filename, ?string $default_filename = null): FreshRSS_UserConfiguration { parent::register('user', $config_filename, $default_filename); return parent::get('user'); diff --git a/app/Models/ViewJavascript.php b/app/Models/ViewJavascript.php index f14810572..62d0339eb 100644 --- a/app/Models/ViewJavascript.php +++ b/app/Models/ViewJavascript.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + final class FreshRSS_ViewJavascript extends FreshRSS_View { /** @var array<FreshRSS_Category> */ diff --git a/app/Models/ViewStats.php b/app/Models/ViewStats.php index 03e0bc00d..9025a86db 100644 --- a/app/Models/ViewStats.php +++ b/app/Models/ViewStats.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + final class FreshRSS_ViewStats extends FreshRSS_View { /** @var FreshRSS_Category|null */ diff --git a/app/Utils/feverUtil.php b/app/Utils/feverUtil.php index 4de321732..c581cd5c4 100644 --- a/app/Utils/feverUtil.php +++ b/app/Utils/feverUtil.php @@ -9,8 +9,11 @@ class FreshRSS_fever_Util { * @return bool true if the path is writable, false otherwise. */ public static function checkFeverPath(): bool { - if (!file_exists(self::FEVER_PATH)) { - @mkdir(self::FEVER_PATH, 0770, true); + if (!file_exists(self::FEVER_PATH) && + !mkdir($concurrentDirectory = self::FEVER_PATH, 0770, true) && + !is_dir($concurrentDirectory) + ) { + throw new \RuntimeException(sprintf('Directory "%s" was not created', $concurrentDirectory)); } $ok = touch(self::FEVER_PATH . '/index.html'); // is_writable() is not reliable for a folder on NFS @@ -22,6 +25,7 @@ class FreshRSS_fever_Util { /** * Return the corresponding path for a fever key. + * @throws FreshRSS_Context_Exception */ public static function getKeyPath(string $feverKey): string { if (FreshRSS_Context::$system_conf === null) { @@ -34,6 +38,7 @@ class FreshRSS_fever_Util { /** * Update the fever key of a user. * @return string|false the Fever key, or false if the update failed + * @throws FreshRSS_Context_Exception */ public static function updateKey(string $username, string $passwordPlain) { if (!self::checkFeverPath()) { @@ -56,6 +61,7 @@ class FreshRSS_fever_Util { * Delete the Fever key of a user. * * @return bool true if the deletion succeeded, else false. + * @throws FreshRSS_Context_Exception */ public static function deleteKey(string $username): bool { $userConfig = get_user_configuration($username); diff --git a/app/install.php b/app/install.php index b42771fbb..a404f6f4d 100644 --- a/app/install.php +++ b/app/install.php @@ -290,7 +290,7 @@ function freshrss_already_installed(): bool { $system_conf = null; try { $system_conf = FreshRSS_SystemConfiguration::init($conf_path); - } catch (Minz_FileNotExistException $e) { + } catch (Minz_ConfigurationNamespaceException $e) { return false; } @@ -298,7 +298,7 @@ function freshrss_already_installed(): bool { $current_user = $system_conf->default_user; try { FreshRSS_UserConfiguration::init(USERS_PATH . '/' . $current_user . '/config.php'); - } catch (Minz_FileNotExistException $e) { + } catch (Minz_ConfigurationNamespaceException $e) { return false; } diff --git a/app/shares.php b/app/shares.php index ba2a49e3f..b3733e1f3 100644 --- a/app/shares.php +++ b/app/shares.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + /* * This is a configuration file. You shouldn’t modify it unless you know what * you are doing. If you want to add a share type, this is where you need to do |
