diff options
Diffstat (limited to 'app/Models')
| -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 |
5 files changed, 31 insertions, 23 deletions
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; } } |
