From 22030155f8fd5cab102ddd897a914cf1a0ffd183 Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Wed, 6 Nov 2019 15:16:00 +0100 Subject: Fix database autocreate at install (#2635) * Fix database autocreate at install Several bugs prevented the auto-creation of the database in Web and CLI installs. Fix https://github.com/YunoHost-Apps/freshrss_ynh/issues/84#issuecomment-549818408 * initDb https://github.com/FreshRSS/FreshRSS/pull/2635#discussion_r343107795 --- cli/do-install.php | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'cli/do-install.php') diff --git a/cli/do-install.php b/cli/do-install.php index dea5d235e..fa6bac8c8 100755 --- a/cli/do-install.php +++ b/cli/do-install.php @@ -82,7 +82,24 @@ if (file_put_contents(join_path(DATA_PATH, 'config.php'), fail('FreshRSS could not write configuration file!: ' . join_path(DATA_PATH, 'config.php')); } -if (!checkDb()) { +if (function_exists('opcache_reset')) { + opcache_reset(); +} + +Minz_Configuration::register('system', DATA_PATH . '/config.php', FRESHRSS_PATH . '/config.default.php'); +FreshRSS_Context::$system_conf = Minz_Configuration::get('system'); + +Minz_Session::_param('currentUser', $config['default_user']); + +$ok = false; +try { + $ok = initDb(); +} catch (Exception $ex) { + $_SESSION['bd_error'] = $ex->getMessage(); + $ok = false; +} + +if (!$ok) { @unlink(join_path(DATA_PATH, 'config.php')); fail('FreshRSS database error: ' . (empty($_SESSION['bd_error']) ? 'Unknown error' : $_SESSION['bd_error'])); } -- cgit v1.2.3