diff options
| author | 2021-03-07 17:34:47 +0100 | |
|---|---|---|
| committer | 2021-03-07 17:34:47 +0100 | |
| commit | b10cd770eeca5520d9beb5e4e2f1a85bfcb75a9b (patch) | |
| tree | 30bf1165ad6f220a4da1a518c1f911dd155a07a2 | |
| parent | 51ed59dcc6825469a5235503dd6fa81b0f7baf41 (diff) | |
SQLite: fix updateEntry (#3461)
* Draft of fix for updateEntry
#fix https://github.com/FreshRSS/FreshRSS/issues/3130
* Fix for SQLite
* Update app/Models/EntryDAO.php
Fixed in https://github.com/FreshRSS/FreshRSS/pull/3500
* Unbuffered streaming only for MySQL
| -rwxr-xr-x | app/Controllers/feedController.php | 12 | ||||
| -rw-r--r-- | app/Models/EntryDAO.php | 63 |
2 files changed, 42 insertions, 33 deletions
diff --git a/app/Controllers/feedController.php b/app/Controllers/feedController.php index 158015d2b..25bada492 100755 --- a/app/Controllers/feedController.php +++ b/app/Controllers/feedController.php @@ -733,10 +733,18 @@ class FreshRSS_feed_Controller extends Minz_ActionController { //Extract all feed entries from database, load complete content and store them back in database. $entries = $entryDAO->listWhere('f', $feed_id, FreshRSS_Entry::STATE_ALL, 'DESC', 0); + //TODO: Parameter to limit the number of articles to reload - //We need another DB connection in parallel + //We need another DB connection in parallel for unbuffered streaming Minz_ModelPdo::$usesSharedPdo = false; - $entryDAO2 = FreshRSS_Factory::createEntryDao(); + if (FreshRSS_Context::$system_conf->db['type'] === 'mysql') { + // Second parallel connection for unbuffered streaming: MySQL + $entryDAO2 = FreshRSS_Factory::createEntryDao(); + } else { + // Single connection for buffered queries (in memory): SQLite, PostgreSQL + //TODO: Consider an unbuffered query for PostgreSQL + $entryDAO2 = $entryDAO; + } foreach ($entries as $entry) { if ($entry->loadCompleteContent(true)) { diff --git a/app/Models/EntryDAO.php b/app/Models/EntryDAO.php index a9bf5a49b..c6c4af62a 100644 --- a/app/Models/EntryDAO.php +++ b/app/Models/EntryDAO.php @@ -194,38 +194,39 @@ SQL; . 'WHERE id_feed=:id_feed AND guid=:guid'; $this->updateEntryPrepared = $this->pdo->prepare($sql); } + if ($this->updateEntryPrepared) { + $valuesTmp['guid'] = substr($valuesTmp['guid'], 0, 760); + $valuesTmp['guid'] = safe_ascii($valuesTmp['guid']); + $this->updateEntryPrepared->bindParam(':guid', $valuesTmp['guid']); + $valuesTmp['title'] = mb_strcut($valuesTmp['title'], 0, 255, 'UTF-8'); + $valuesTmp['title'] = safe_utf8($valuesTmp['title']); + $this->updateEntryPrepared->bindParam(':title', $valuesTmp['title']); + $valuesTmp['author'] = mb_strcut($valuesTmp['author'], 0, 255, 'UTF-8'); + $valuesTmp['author'] = safe_utf8($valuesTmp['author']); + $this->updateEntryPrepared->bindParam(':author', $valuesTmp['author']); + $valuesTmp['content'] = safe_utf8($valuesTmp['content']); + $this->updateEntryPrepared->bindParam(':content', $valuesTmp['content']); + $valuesTmp['link'] = substr($valuesTmp['link'], 0, 1023); + $valuesTmp['link'] = safe_ascii($valuesTmp['link']); + $this->updateEntryPrepared->bindParam(':link', $valuesTmp['link']); + $valuesTmp['date'] = min($valuesTmp['date'], 2147483647); + $this->updateEntryPrepared->bindParam(':date', $valuesTmp['date'], PDO::PARAM_INT); + $valuesTmp['lastSeen'] = time(); + $this->updateEntryPrepared->bindParam(':last_seen', $valuesTmp['lastSeen'], PDO::PARAM_INT); + if ($valuesTmp['is_read'] !== null) { + $this->updateEntryPrepared->bindValue(':is_read', $valuesTmp['is_read'] ? 1 : 0, PDO::PARAM_INT); + } + $this->updateEntryPrepared->bindParam(':id_feed', $valuesTmp['id_feed'], PDO::PARAM_INT); + $valuesTmp['tags'] = mb_strcut($valuesTmp['tags'], 0, 1023, 'UTF-8'); + $valuesTmp['tags'] = safe_utf8($valuesTmp['tags']); + $this->updateEntryPrepared->bindParam(':tags', $valuesTmp['tags']); - $valuesTmp['guid'] = substr($valuesTmp['guid'], 0, 760); - $valuesTmp['guid'] = safe_ascii($valuesTmp['guid']); - $this->updateEntryPrepared->bindParam(':guid', $valuesTmp['guid']); - $valuesTmp['title'] = mb_strcut($valuesTmp['title'], 0, 255, 'UTF-8'); - $valuesTmp['title'] = safe_utf8($valuesTmp['title']); - $this->updateEntryPrepared->bindParam(':title', $valuesTmp['title']); - $valuesTmp['author'] = mb_strcut($valuesTmp['author'], 0, 255, 'UTF-8'); - $valuesTmp['author'] = safe_utf8($valuesTmp['author']); - $this->updateEntryPrepared->bindParam(':author', $valuesTmp['author']); - $valuesTmp['content'] = safe_utf8($valuesTmp['content']); - $this->updateEntryPrepared->bindParam(':content', $valuesTmp['content']); - $valuesTmp['link'] = substr($valuesTmp['link'], 0, 1023); - $valuesTmp['link'] = safe_ascii($valuesTmp['link']); - $this->updateEntryPrepared->bindParam(':link', $valuesTmp['link']); - $valuesTmp['date'] = min($valuesTmp['date'], 2147483647); - $this->updateEntryPrepared->bindParam(':date', $valuesTmp['date'], PDO::PARAM_INT); - $valuesTmp['lastSeen'] = time(); - $this->updateEntryPrepared->bindParam(':last_seen', $valuesTmp['lastSeen'], PDO::PARAM_INT); - if ($valuesTmp['is_read'] !== null) { - $this->updateEntryPrepared->bindValue(':is_read', $valuesTmp['is_read'] ? 1 : 0, PDO::PARAM_INT); - } - $this->updateEntryPrepared->bindParam(':id_feed', $valuesTmp['id_feed'], PDO::PARAM_INT); - $valuesTmp['tags'] = mb_strcut($valuesTmp['tags'], 0, 1023, 'UTF-8'); - $valuesTmp['tags'] = safe_utf8($valuesTmp['tags']); - $this->updateEntryPrepared->bindParam(':tags', $valuesTmp['tags']); - - if ($this->hasNativeHex()) { - $this->updateEntryPrepared->bindParam(':hash', $valuesTmp['hash']); - } else { - $valuesTmp['hashBin'] = hex2bin($valuesTmp['hash']); - $this->updateEntryPrepared->bindParam(':hash', $valuesTmp['hashBin']); + if ($this->hasNativeHex()) { + $this->updateEntryPrepared->bindParam(':hash', $valuesTmp['hash']); + } else { + $valuesTmp['hashBin'] = hex2bin($valuesTmp['hash']); + $this->updateEntryPrepared->bindParam(':hash', $valuesTmp['hashBin']); + } } if ($this->updateEntryPrepared && $this->updateEntryPrepared->execute()) { |
