A free, self-hostable news aggregator…
Defered insertion MySQL bug
Alexandre Alapetitea20fd9db9f0e
diff --git a/app/Controllers/feedController.php b/app/Controllers/feedController.phpindex a2d9d5c35..b565d0439 100755--- a/app/Controllers/feedController.php+++ b/app/Controllers/feedController.php@@ -436,6 +436,7 @@ class FreshRSS_feed_Controller extends Minz_ActionController {}if (!$noCommit) {$entryDAO->commitNewEntries();+ $feedDAO->updateCachedValues(); //TODO: Optimize}return array($updated_feeds, reset($feeds));}diff --git a/app/Models/EntryDAO.php b/app/Models/EntryDAO.phpindex decae9307..9d11cec6a 100644--- a/app/Models/EntryDAO.php+++ b/app/Models/EntryDAO.php@@ -121,6 +121,7 @@ class FreshRSS_EntryDAO extends Minz_ModelPdo implements FreshRSS_Searchable {}protected function autoUpdateDb($errorInfo) {+ Minz_Log::warning('FreshRSS_EntryDAO::autoUpdateDb: ' . print_r($errorInfo, true));if (isset($errorInfo[0])) {if ($errorInfo[0] === '42S22') { //ER_BAD_FIELD_ERROR//autoAddColumn@@ -202,16 +203,15 @@ class FreshRSS_EntryDAO extends Minz_ModelPdo implements FreshRSS_Searchable {}public function commitNewEntries() {- $sql = 'SET @rank=SELECT MAX(id) - COUNT(*) FROM `' . $this->prefix . 'entrytmp`; ' . //MySQL-specific+ $sql = 'SET @rank=(SELECT MAX(id) - COUNT(*) FROM `' . $this->prefix . 'entrytmp`); ' . //MySQL-specific'INSERT IGNORE INTO `' . $this->prefix . 'entry` (id, guid, title, author, content_bin, link, date, `lastSeen`, hash, is_read, is_favorite, id_feed, tags) ' .'SELECT @rank:=@rank+1 AS id, guid, title, author, content_bin, link, date, `lastSeen`, hash, is_read, is_favorite, id_feed, tags FROM `' . $this->prefix . 'entrytmp` ORDER BY date; ' .'DELETE FROM `' . $this->prefix . 'entrytmp` WHERE id <= @rank;';- $stm = $this->bd->prepare($sql);$hadTransaction = $this->bd->inTransaction();if (!$hadTransaction) {$this->bd->beginTransaction();}- $result = $stm ? $stm->execute() : false;+ $result = $this->bd->exec($sql) !== false;if (!$hadTransaction) {$this->bd->commit();}diff --git a/app/SQL/install.sql.mysql.php b/app/SQL/install.sql.mysql.phpindex ceca07f93..f42e08ad3 100644--- a/app/SQL/install.sql.mysql.php+++ b/app/SQL/install.sql.mysql.php@@ -79,7 +79,7 @@ CREATE TABLE IF NOT EXISTS `%1$sentrytmp` ( -- v1.7PRIMARY KEY (`id`),FOREIGN KEY (`id_feed`) REFERENCES `%1$sfeed`(`id`) ON DELETE CASCADE ON UPDATE CASCADE,UNIQUE KEY (`id_feed`,`guid`),- INDEX (`date`),+ INDEX (`date`)) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ciENGINE = INNODB;');