diff options
| author | 2025-11-11 08:17:12 +0100 | |
|---|---|---|
| committer | 2025-11-11 08:17:12 +0100 | |
| commit | a18c35046daee15e7ac5f85db290d54541a03e3c (patch) | |
| tree | ec638cf7c93537a4f81b27216097d8509252eb81 /app/Controllers/updateController.php | |
| parent | 5e622c60fa5c40793138807280319f7e84d00cc6 (diff) | |
Housekeeping lib_rss.php (#8193)
* Housekeeping lib_rss.php
`lib_rss.php` had become much too large, especially after https://github.com/FreshRSS/FreshRSS/pull/7924
Moved most functions to other places.
Mostly no change of code otherwise (see comments).
* Extension: composer run-script phpstan-third-party
Diffstat (limited to 'app/Controllers/updateController.php')
| -rw-r--r-- | app/Controllers/updateController.php | 77 |
1 files changed, 74 insertions, 3 deletions
diff --git a/app/Controllers/updateController.php b/app/Controllers/updateController.php index 7c204de8c..98d552688 100644 --- a/app/Controllers/updateController.php +++ b/app/Controllers/updateController.php @@ -335,13 +335,84 @@ class FreshRSS_update_Controller extends FreshRSS_ActionController { } /** + * Check PHP and its extensions are well-installed. + * + * @return array<string,bool> of tested values. + */ + private static function check_install_php(): array { + $pdo_mysql = extension_loaded('pdo_mysql'); + $pdo_pgsql = extension_loaded('pdo_pgsql'); + $pdo_sqlite = extension_loaded('pdo_sqlite'); + return [ + 'php' => version_compare(PHP_VERSION, FRESHRSS_MIN_PHP_VERSION) >= 0, + 'curl' => extension_loaded('curl'), + 'pdo' => $pdo_mysql || $pdo_sqlite || $pdo_pgsql, + 'pcre' => extension_loaded('pcre'), + 'ctype' => extension_loaded('ctype'), + 'fileinfo' => extension_loaded('fileinfo'), + 'dom' => class_exists('DOMDocument'), + 'json' => extension_loaded('json'), + 'mbstring' => extension_loaded('mbstring'), + 'zip' => extension_loaded('zip'), + ]; + } + + /** + * Check different data files and directories exist. + * @return array<string,bool> of tested values. + */ + private static function check_install_files(): array { + return [ + 'data' => is_dir(DATA_PATH) && touch(DATA_PATH . '/index.html'), // is_writable() is not reliable for a folder on NFS + 'cache' => is_dir(CACHE_PATH) && touch(CACHE_PATH . '/index.html'), + 'users' => is_dir(USERS_PATH) && touch(USERS_PATH . '/index.html'), + 'favicons' => is_dir(DATA_PATH) && touch(DATA_PATH . '/favicons/index.html'), + 'tokens' => is_dir(DATA_PATH) && touch(DATA_PATH . '/tokens/index.html'), + ]; + } + + /** + * Check database is well-installed. + * + * @return array<string,bool> of tested values. + */ + private static function check_install_database(): array { + $status = [ + 'connection' => true, + 'tables' => false, + 'categories' => false, + 'feeds' => false, + 'entries' => false, + 'entrytmp' => false, + 'tag' => false, + 'entrytag' => false, + ]; + + try { + $dbDAO = FreshRSS_Factory::createDatabaseDAO(); + + $status['tables'] = $dbDAO->tablesAreCorrect(); + $status['categories'] = $dbDAO->categoryIsCorrect(); + $status['feeds'] = $dbDAO->feedIsCorrect(); + $status['entries'] = $dbDAO->entryIsCorrect(); + $status['entrytmp'] = $dbDAO->entrytmpIsCorrect(); + $status['tag'] = $dbDAO->tagIsCorrect(); + $status['entrytag'] = $dbDAO->entrytagIsCorrect(); + } catch (Minz_PDOConnectionException $e) { + $status['connection'] = false; + } + + return $status; + } + + /** * This action displays information about installation. */ public function checkInstallAction(): void { FreshRSS_View::prependTitle(_t('admin.check_install.title') . ' ยท '); - $this->view->status_php = check_install_php(); - $this->view->status_files = check_install_files(); - $this->view->status_database = check_install_database(); + $this->view->status_php = self::check_install_php(); + $this->view->status_files = self::check_install_files(); + $this->view->status_database = self::check_install_database(); } } |
