diff options
| author | 2019-11-06 21:54:13 +0100 | |
|---|---|---|
| committer | 2019-11-06 21:54:13 +0100 | |
| commit | 91cb165829badde07c42a002215cf52779d891b6 (patch) | |
| tree | b8ee6e04e32dcf6c6fc25b7b0b9fe2952d2991ba /app | |
| parent | 3aa66f317b496ccd9a2df914bbc747c52081a7ad (diff) | |
| parent | 6d596e9e54308297d423b23bf65338d62eebc415 (diff) | |
Merge pull request #2633 from FreshRSS/dev1.15.1
FreshRSS 1.15.1
Diffstat (limited to 'app')
| -rw-r--r-- | app/Controllers/updateController.php | 20 | ||||
| -rw-r--r-- | app/Controllers/userController.php | 16 | ||||
| -rw-r--r-- | app/Models/CategoryDAO.php | 13 | ||||
| -rw-r--r-- | app/Models/DatabaseDAO.php | 3 | ||||
| -rw-r--r-- | app/Models/DatabaseDAOPGSQL.php | 15 | ||||
| -rw-r--r-- | app/Models/FeedDAO.php | 4 | ||||
| -rw-r--r-- | app/Models/UserDAO.php | 19 | ||||
| -rw-r--r-- | app/SQL/install.sql.mysql.php | 5 | ||||
| -rw-r--r-- | app/SQL/install.sql.pgsql.php | 6 | ||||
| -rw-r--r-- | app/SQL/install.sql.sqlite.php | 5 | ||||
| -rw-r--r-- | app/install.php | 10 |
11 files changed, 66 insertions, 50 deletions
diff --git a/app/Controllers/updateController.php b/app/Controllers/updateController.php index ebe5e4cc8..c0c1ef1c8 100644 --- a/app/Controllers/updateController.php +++ b/app/Controllers/updateController.php @@ -23,26 +23,28 @@ class FreshRSS_update_Controller extends Minz_ActionController { } chdir($cwd); $line = is_array($output) ? implode('; ', $output) : '' . $output; - return strpos($line, '[behind') !== false; + return strpos($line, '[behind') !== false || strpos($line, '[ahead') !== false; } public static function gitPull() { $cwd = getcwd(); chdir(FRESHRSS_PATH); - $output = array(); + $output = ''; $return = 1; try { - exec('git clean -f -d -f', $output, $return); + exec('git fetch', $output, $return); if ($return == 0) { - exec('git pull --ff-only', $output, $return); - } else { - $line = is_array($output) ? implode('; ', $output) : '' . $output; - Minz_Log::warning('git clean warning:' . $line); + exec('git reset --hard FETCH_HEAD', $output, $return); } } catch (Exception $e) { - Minz_Log::warning('git pull error:' . $e->getMessage()); + Minz_Log::warning('Git error:' . $e->getMessage()); + if ($output == '') { + $output = $e->getMessage(); + } + $return = 1; } chdir($cwd); + deleteInstall(); $line = is_array($output) ? implode('; ', $output) : '' . $output; return $return == 0 ? true : 'Git error: ' . $line; } @@ -52,6 +54,8 @@ class FreshRSS_update_Controller extends Minz_ActionController { Minz_Error::error(403); } + include_once(LIB_PATH . '/lib_install.php'); + invalidateHttpCache(); $this->view->update_to_apply = false; diff --git a/app/Controllers/userController.php b/app/Controllers/userController.php index 6afc91b4e..7ce6b298a 100644 --- a/app/Controllers/userController.php +++ b/app/Controllers/userController.php @@ -248,7 +248,21 @@ class FreshRSS_user_Controller extends Minz_ActionController { } if ($ok) { $newUserDAO = FreshRSS_Factory::createUserDao($new_user_name); - $ok &= $newUserDAO->createUser($insertDefaultFeeds); + $ok &= $newUserDAO->createUser(); + + if ($ok && $insertDefaultFeeds) { + $opmlPath = DATA_PATH . '/opml.xml'; + if (!file_exists($opmlPath)) { + $opmlPath = FRESHRSS_PATH . '/opml.default.xml'; + } + $importController = new FreshRSS_importExport_Controller(); + try { + $importController->importFile($opmlPath, $opmlPath, $new_user_name); + } catch (Exception $e) { + Minz_Log::error('Error while importing default OPML for user ' . $new_user_name . ': ' . $e->getMessage()); + } + } + $ok &= self::updateUser($new_user_name, $email, $passwordPlain, $apiPasswordPlain); } return $ok; diff --git a/app/Models/CategoryDAO.php b/app/Models/CategoryDAO.php index c1277751c..08dc4eef0 100644 --- a/app/Models/CategoryDAO.php +++ b/app/Models/CategoryDAO.php @@ -4,6 +4,16 @@ class FreshRSS_CategoryDAO extends Minz_ModelPdo implements FreshRSS_Searchable const DEFAULTCATEGORYID = 1; + public function resetDefaultCategoryName() { + //FreshRSS 1.15.1 + $stm = $this->pdo->prepare('UPDATE `_category` SET name = :name WHERE id = :id'); + if ($stm) { + $stm->bindValue(':id', self::DEFAULTCATEGORYID, PDO::PARAM_INT); + $stm->bindValue(':name', 'Uncategorized'); + } + return $stm && $stm->execute(); + } + protected function addColumn($name) { Minz_Log::warning(__method__ . ': ' . $name); try { @@ -45,6 +55,9 @@ class FreshRSS_CategoryDAO extends Minz_ModelPdo implements FreshRSS_Searchable } else { $this->pdo->exec('DROP INDEX IF EXISTS feed_keep_history_index'); //SQLite at least drop index } + + $this->resetDefaultCategoryName(); + return $ok; } } catch (Exception $e) { diff --git a/app/Models/DatabaseDAO.php b/app/Models/DatabaseDAO.php index a36b469b1..13330db23 100644 --- a/app/Models/DatabaseDAO.php +++ b/app/Models/DatabaseDAO.php @@ -178,6 +178,9 @@ class FreshRSS_DatabaseDAO extends Minz_ModelPdo { } public function minorDbMaintenance() { + $catDAO = FreshRSS_Factory::createCategoryDao(); + $catDAO->resetDefaultCategoryName(); + $this->ensureCaseInsensitiveGuids(); } diff --git a/app/Models/DatabaseDAOPGSQL.php b/app/Models/DatabaseDAOPGSQL.php index 1a6b3599e..7ca7799ae 100644 --- a/app/Models/DatabaseDAOPGSQL.php +++ b/app/Models/DatabaseDAOPGSQL.php @@ -58,14 +58,17 @@ class FreshRSS_DatabaseDAOPGSQL extends FreshRSS_DatabaseDAOSQLite { $stm->execute(); } else { $sql = "SELECT " - . "pg_total_relation_size('{$this->pdo->prefix()}category') + " - . "pg_total_relation_size('{$this->pdo->prefix()}feed') + " - . "pg_total_relation_size('{$this->pdo->prefix()}entry') + " - . "pg_total_relation_size('{$this->pdo->prefix()}entrytmp') + " - . "pg_total_relation_size('{$this->pdo->prefix()}tag') + " - . "pg_total_relation_size('{$this->pdo->prefix()}entrytag')"; + . "pg_total_relation_size('`{$this->pdo->prefix()}category`') + " + . "pg_total_relation_size('`{$this->pdo->prefix()}feed`') + " + . "pg_total_relation_size('`{$this->pdo->prefix()}entry`') + " + . "pg_total_relation_size('`{$this->pdo->prefix()}entrytmp`') + " + . "pg_total_relation_size('`{$this->pdo->prefix()}tag`') + " + . "pg_total_relation_size('`{$this->pdo->prefix()}entrytag`')"; $stm = $this->pdo->query($sql); } + if ($stm == false) { + return 0; + } $res = $stm->fetchAll(PDO::FETCH_COLUMN, 0); return $res[0]; } diff --git a/app/Models/FeedDAO.php b/app/Models/FeedDAO.php index fa0001df7..2bff50d52 100644 --- a/app/Models/FeedDAO.php +++ b/app/Models/FeedDAO.php @@ -102,7 +102,9 @@ class FreshRSS_FeedDAO extends Minz_ModelPdo implements FreshRSS_Searchable { 'httpAuth' => $feed->httpAuth(), 'attributes' => $feed->attributes(), ); - if ($feed->mute() || $feed->ttl() != FreshRSS_Context::$user_conf->ttl_default) { + if ($feed->mute() || ( + FreshRSS_Context::$user_conf != null && //When creating a new user + $feed->ttl() != FreshRSS_Context::$user_conf->ttl_default)) { $values['ttl'] = $feed->ttl() * ($feed->mute() ? -1 : 1); } diff --git a/app/Models/UserDAO.php b/app/Models/UserDAO.php index 4e824cf01..266c8bc0e 100644 --- a/app/Models/UserDAO.php +++ b/app/Models/UserDAO.php @@ -1,34 +1,21 @@ <?php class FreshRSS_UserDAO extends Minz_ModelPdo { - public function createUser($insertDefaultFeeds = false) { + public function createUser() { require(APP_PATH . '/SQL/install.sql.' . $this->pdo->dbType() . '.php'); try { $sql = $SQL_CREATE_TABLES . $SQL_CREATE_TABLE_ENTRYTMP . $SQL_CREATE_TABLE_TAGS; $ok = $this->pdo->exec($sql) !== false; //Note: Only exec() can take multiple statements safely. - if ($ok && $insertDefaultFeeds) { - $default_feeds = FreshRSS_Context::$system_conf->default_feeds; - $stm = $this->pdo->prepare($SQL_INSERT_FEED); - foreach ($default_feeds as $feed) { - $parameters = [ - ':url' => $feed['url'], - ':name' => $feed['name'], - ':website' => $feed['website'], - ':description' => $feed['description'], - ]; - $ok &= ($stm && $stm->execute($parameters)); - } - } } catch (Exception $e) { - Minz_Log::error('Error while creating database for user: ' . $e->getMessage()); + Minz_Log::error('Error while creating database for user ' . $this->current_user . ': ' . $e->getMessage()); } if ($ok) { return true; } else { $info = empty($stm) ? $this->pdo->errorInfo() : $stm->errorInfo(); - Minz_Log::error(__METHOD__ . ' error: ' . $info[2]); + Minz_Log::error(__METHOD__ . ' error: ' . json_encode($info)); return false; } } diff --git a/app/SQL/install.sql.mysql.php b/app/SQL/install.sql.mysql.php index 1eabfae8b..f8972b186 100644 --- a/app/SQL/install.sql.mysql.php +++ b/app/SQL/install.sql.mysql.php @@ -112,11 +112,6 @@ CREATE TABLE IF NOT EXISTS `_entrytag` ( -- v1.12 ENGINE = INNODB; SQL; -$SQL_INSERT_FEED = <<<'SQL' -INSERT IGNORE INTO `_feed` (url, category, name, website, description, ttl) - VALUES(:url, 1, :name, :website, :description, 86400); -SQL; - $SQL_DROP_TABLES = <<<'SQL' DROP TABLE IF EXISTS `_entrytag`, `_tag`, `_entrytmp`, `_entry`, `_feed`, `_category`; SQL; diff --git a/app/SQL/install.sql.pgsql.php b/app/SQL/install.sql.pgsql.php index 53afc8a17..c17a45127 100644 --- a/app/SQL/install.sql.pgsql.php +++ b/app/SQL/install.sql.pgsql.php @@ -100,12 +100,6 @@ CREATE TABLE IF NOT EXISTS `_entrytag` ( CREATE INDEX IF NOT EXISTS `_entrytag_id_entry_index` ON `_entrytag` ("id_entry"); SQL; -$SQL_INSERT_FEED = <<<'SQL' -INSERT INTO `_feed` (url, category, name, website, description, ttl) - SELECT :url::VARCHAR, 1, :name, :website, :description, 86400 - WHERE NOT EXISTS (SELECT id FROM `_feed` WHERE url = :url); -SQL; - $SQL_DROP_TABLES = <<<'SQL' DROP TABLE IF EXISTS `_entrytag`, `_tag`, `_entrytmp`, `_entry`, `_feed`, `_category`; SQL; diff --git a/app/SQL/install.sql.sqlite.php b/app/SQL/install.sql.sqlite.php index 2a4763637..ff7c03354 100644 --- a/app/SQL/install.sql.sqlite.php +++ b/app/SQL/install.sql.sqlite.php @@ -102,11 +102,6 @@ CREATE TABLE IF NOT EXISTS `entrytag` ( CREATE INDEX IF NOT EXISTS entrytag_id_entry_index ON `entrytag` (`id_entry`); SQL; -$SQL_INSERT_FEED = <<<'SQL' -INSERT OR IGNORE INTO `feed` (url, category, name, website, description, ttl) - VALUES(:url, 1, :name, :website, :description, 86400); -SQL; - $SQL_DROP_TABLES = <<<'SQL' DROP TABLE IF EXISTS `entrytag`; DROP TABLE IF EXISTS `tag`; diff --git a/app/install.php b/app/install.php index 96bee34a1..557ae9eab 100644 --- a/app/install.php +++ b/app/install.php @@ -132,7 +132,7 @@ function saveStep2() { $config_array = [ 'salt' => generateSalt(), 'base_url' => $base_url, - 'default_user' => 'admin', + 'default_user' => '_', 'db' => [ 'type' => $_SESSION['bd_type'], 'host' => $_SESSION['bd_host'], @@ -154,12 +154,18 @@ function saveStep2() { @unlink(DATA_PATH . '/config.php'); //To avoid access-rights problems file_put_contents(DATA_PATH . '/config.php', "<?php\n return " . var_export($config_array, true) . ";\n"); + 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'); $ok = false; try { - $ok = checkDb(); + Minz_Session::_param('currentUser', $config_array['default_user']); + $ok = initDb(); + Minz_Session::_param('currentUser'); } catch (Exception $ex) { $_SESSION['bd_error'] = $ex->getMessage(); $ok = false; |
