A free, self-hostable news aggregator…
SQL: update request for updated articles
Alexandre Alapetite7f7de31c1dcb
diff --git a/app/Controllers/feedController.php b/app/Controllers/feedController.phpindex 08a0257a2..59c9174fb 100755--- a/app/Controllers/feedController.php+++ b/app/Controllers/feedController.php@@ -343,7 +343,7 @@ class FreshRSS_feed_Controller extends Minz_ActionController {} else { //This entry already exists but has been updatedMinz_Log::debug('Entry with GUID `' . $entry->guid() . '` updated in feed ' . $feed->id() .', old hash ' . $existingHash . ', new hash ' . $entry->hash());- $entry->_isRead($is_read); //Reset is_read+ $entry->_isRead(null); //Change is_read according to policy. //TODO: Implement optionif (!$entryDAO->hasTransaction()) {$entryDAO->beginTransaction();}diff --git a/app/Models/Entry.php b/app/Models/Entry.phpindex 6931c9f25..a562a963a 100644--- a/app/Models/Entry.php+++ b/app/Models/Entry.php@@ -15,7 +15,7 @@ class FreshRSS_Entry extends Minz_Model {private $link;private $date;private $hash = null;- private $is_read;+ private $is_read; //Nullable booleanprivate $is_favorite;private $feed;private $tags;@@ -125,7 +125,7 @@ class FreshRSS_Entry extends Minz_Model {$this->date = $value > 1 ? $value : time();}public function _isRead($value) {- $this->is_read = $value;+ $this->is_read = $value === null ? null : (bool)$value;}public function _isFavorite($value) {$this->is_favorite = $value;diff --git a/app/Models/EntryDAO.php b/app/Models/EntryDAO.phpindex 5b4b85547..543b61573 100644--- a/app/Models/EntryDAO.php+++ b/app/Models/EntryDAO.php@@ -91,11 +91,17 @@ class FreshRSS_EntryDAO extends Minz_ModelPdo implements FreshRSS_Searchable {private $updateEntryPrepared = null;public function updateEntry($valuesTmp) {+ if (!isset($valuesTmp['is_read'])) {+ $valuesTmp['is_read'] = null;+ }+if ($this->updateEntryPrepared === null) {$sql = 'UPDATE `' . $this->prefix . 'entry` '. 'SET title=?, author=?, '. ($this->isCompressed() ? 'content_bin=COMPRESS(?)' : 'content=?')- . ', link=?, date=?, lastSeen=?, hash=X?, is_read=?, tags=? '+ . ', link=?, date=?, lastSeen=?, hash=X?, '+ . ($valuesTmp['is_read'] === null ? '' : 'is_read=?, ')+ . 'tags=? '. 'WHERE id_feed=? AND guid=?';$this->updateEntryPrepared = $this->bd->prepare($sql);}@@ -108,11 +114,15 @@ class FreshRSS_EntryDAO extends Minz_ModelPdo implements FreshRSS_Searchable {$valuesTmp['date'],time(),$valuesTmp['hash'],- $valuesTmp['is_read'] ? 1 : 0,+ );+ if ($valuesTmp['is_read'] !== null) {+ $values[] = $valuesTmp['is_read'] ? 1 : 0;+ }+ $values = array_merge($values, array(substr($valuesTmp['tags'], 0, 1023),$valuesTmp['id_feed'],substr($valuesTmp['guid'], 0, 760),- );+ ));if ($this->updateEntryPrepared && $this->updateEntryPrepared->execute($values)) {return $this->bd->lastInsertId();