diff options
| author | 2022-07-19 15:17:08 +0200 | |
|---|---|---|
| committer | 2022-07-19 15:17:08 +0200 | |
| commit | 0866fdaee85bc8530437436abe7f8536b8b0f4f0 (patch) | |
| tree | fd73e2e55740423bfab64581c4934b6d50dd3162 /app/Models/EntryDAOPGSQL.php | |
| parent | 2d807e06b1abffdbc40a60c3623e22e3c6b818c6 (diff) | |
Add database field attributes for entries (#4444)
* Add database field attributes for entries
Just like we already have for categories, feeds, etc.
No core use yet, but allows in particular extensions to save per-entry data
* Fix PHPStand
* Fix wrong variable
Diffstat (limited to 'app/Models/EntryDAOPGSQL.php')
| -rw-r--r-- | app/Models/EntryDAOPGSQL.php | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/app/Models/EntryDAOPGSQL.php b/app/Models/EntryDAOPGSQL.php index 13bf8b41f..8702db706 100644 --- a/app/Models/EntryDAOPGSQL.php +++ b/app/Models/EntryDAOPGSQL.php @@ -20,6 +20,14 @@ class FreshRSS_EntryDAOPGSQL extends FreshRSS_EntryDAOSQLite { protected function autoUpdateDb(array $errorInfo) { if (isset($errorInfo[0])) { + if ($errorInfo[0] === FreshRSS_DatabaseDAO::ER_BAD_FIELD_ERROR || $errorInfo[0] === FreshRSS_DatabaseDAOPGSQL::UNDEFINED_COLUMN) { + $errorLines = explode("\n", $errorInfo[2], 2); // The relevant column name is on the first line, other lines are noise + foreach (['attributes'] as $column) { + if (stripos($errorLines[0], $column) !== false) { + return $this->addColumn($column); + } + } + } if ($errorInfo[0] === FreshRSS_DatabaseDAOPGSQL::UNDEFINED_TABLE) { if (stripos($errorInfo[2], 'tag') !== false) { $tagDAO = FreshRSS_Factory::createTagDao(); @@ -32,10 +40,6 @@ class FreshRSS_EntryDAOPGSQL extends FreshRSS_EntryDAOSQLite { return false; } - protected function addColumn(string $name) { - return false; - } - public function commitNewEntries() { //TODO: Update to PostgreSQL 9.5+ syntax with ON CONFLICT DO NOTHING $sql = 'DO $$ @@ -44,9 +48,9 @@ maxrank bigint := (SELECT MAX(id) FROM `_entrytmp`); rank bigint := (SELECT maxrank - COUNT(*) FROM `_entrytmp`); BEGIN INSERT INTO `_entry` - (id, guid, title, author, content, link, date, `lastSeen`, hash, is_read, is_favorite, id_feed, tags) + (id, guid, title, author, content, link, date, `lastSeen`, hash, is_read, is_favorite, id_feed, tags, attributes) (SELECT rank + row_number() OVER(ORDER BY date, id) AS id, guid, title, author, content, - link, date, `lastSeen`, hash, is_read, is_favorite, id_feed, tags + link, date, `lastSeen`, hash, is_read, is_favorite, id_feed, tags, attributes FROM `_entrytmp` AS etmp WHERE NOT EXISTS ( SELECT 1 FROM `_entry` AS ereal |
