Skip to content

A free, self-hostable news aggregator…

Merge branch 'FreshRSS/dev' into defered-insertion

Alexandre Alapetitefbdc22f75a89
diff --cc app/Controllers/importExportController.php
index ededfe506,af3c0bf46..82c49cc6a
--- a/app/Controllers/importExportController.php
+++ b/app/Controllers/importExportController.php
@@@ -464,18 -464,16 +464,17 @@@ class FreshRSS_importExport_Controller
}
$values = $entry->toArray();
+ $ok = false;
if (isset($existingHashForGuids[$entry->guid()])) {
- $id = $this->entryDAO->updateEntry($values);
+ $ok = $this->entryDAO->updateEntry($values);
} else {
- $id = $this->entryDAO->addEntry($values);
+ $ok = $this->entryDAO->addEntry($values);
}
+ $error |= ($ok === false);
- if (!$error && ($id === false)) {
- $error = true;
- }
}
$this->entryDAO->commit();
+ $entryDAO->commitNewEntries();
return !$error;
}
diff --cc app/Models/EntryDAO.php
index 39c00f01c,96790c69c..61ec48d08
--- a/app/Models/EntryDAO.php
+++ b/app/Models/EntryDAO.php
@@@ -155,45 -121,43 +155,45 @@@ class FreshRSS_EntryDAO extends Minz_Mo
. ', :is_read, :is_favorite, :id_feed, :tags)';
$this->addEntryPrepared = $this->bd->prepare($sql);
}
- $this->addEntryPrepared->bindParam(':id', $valuesTmp['id']);
- $valuesTmp['guid'] = substr($valuesTmp['guid'], 0, 760);
- $valuesTmp['guid'] = safe_ascii($valuesTmp['guid']);
- $this->addEntryPrepared->bindParam(':guid', $valuesTmp['guid']);
- $valuesTmp['title'] = substr($valuesTmp['title'], 0, 255);
- $this->addEntryPrepared->bindParam(':title', $valuesTmp['title']);
- $valuesTmp['author'] = substr($valuesTmp['author'], 0, 255);
- $this->addEntryPrepared->bindParam(':author', $valuesTmp['author']);
- $this->addEntryPrepared->bindParam(':content', $valuesTmp['content']);
- $valuesTmp['link'] = substr($valuesTmp['link'], 0, 1023);
- $valuesTmp['link'] = safe_ascii($valuesTmp['link']);
- $this->addEntryPrepared->bindParam(':link', $valuesTmp['link']);
- $this->addEntryPrepared->bindParam(':date', $valuesTmp['date'], PDO::PARAM_INT);
- $valuesTmp['lastSeen'] = time();
- $this->addEntryPrepared->bindParam(':last_seen', $valuesTmp['lastSeen'], PDO::PARAM_INT);
- $valuesTmp['is_read'] = $valuesTmp['is_read'] ? 1 : 0;
- $this->addEntryPrepared->bindParam(':is_read', $valuesTmp['is_read'], PDO::PARAM_INT);
- $valuesTmp['is_favorite'] = $valuesTmp['is_favorite'] ? 1 : 0;
- $this->addEntryPrepared->bindParam(':is_favorite', $valuesTmp['is_favorite'], PDO::PARAM_INT);
- $this->addEntryPrepared->bindParam(':id_feed', $valuesTmp['id_feed'], PDO::PARAM_INT);
- $valuesTmp['tags'] = substr($valuesTmp['tags'], 0, 1023);
- $this->addEntryPrepared->bindParam(':tags', $valuesTmp['tags']);
-
- if ($this->hasNativeHex()) {
- $this->addEntryPrepared->bindParam(':hash', $valuesTmp['hash']);
- } else {
- $valuesTmp['hashBin'] = pack('H*', $valuesTmp['hash']); //hex2bin() is PHP5.4+
- $this->addEntryPrepared->bindParam(':hash', $valuesTmp['hashBin']);
+ if ($this->addEntryPrepared) {
+ $this->addEntryPrepared->bindParam(':id', $valuesTmp['id']);
+ $valuesTmp['guid'] = substr($valuesTmp['guid'], 0, 760);
+ $valuesTmp['guid'] = safe_ascii($valuesTmp['guid']);
+ $this->addEntryPrepared->bindParam(':guid', $valuesTmp['guid']);
+ $valuesTmp['title'] = substr($valuesTmp['title'], 0, 255);
+ $this->addEntryPrepared->bindParam(':title', $valuesTmp['title']);
+ $valuesTmp['author'] = substr($valuesTmp['author'], 0, 255);
+ $this->addEntryPrepared->bindParam(':author', $valuesTmp['author']);
+ $this->addEntryPrepared->bindParam(':content', $valuesTmp['content']);
+ $valuesTmp['link'] = substr($valuesTmp['link'], 0, 1023);
+ $valuesTmp['link'] = safe_ascii($valuesTmp['link']);
+ $this->addEntryPrepared->bindParam(':link', $valuesTmp['link']);
+ $this->addEntryPrepared->bindParam(':date', $valuesTmp['date'], PDO::PARAM_INT);
+ $valuesTmp['lastSeen'] = time();
+ $this->addEntryPrepared->bindParam(':last_seen', $valuesTmp['lastSeen'], PDO::PARAM_INT);
+ $valuesTmp['is_read'] = $valuesTmp['is_read'] ? 1 : 0;
+ $this->addEntryPrepared->bindParam(':is_read', $valuesTmp['is_read'], PDO::PARAM_INT);
+ $valuesTmp['is_favorite'] = $valuesTmp['is_favorite'] ? 1 : 0;
+ $this->addEntryPrepared->bindParam(':is_favorite', $valuesTmp['is_favorite'], PDO::PARAM_INT);
+ $this->addEntryPrepared->bindParam(':id_feed', $valuesTmp['id_feed'], PDO::PARAM_INT);
+ $valuesTmp['tags'] = substr($valuesTmp['tags'], 0, 1023);
+ $this->addEntryPrepared->bindParam(':tags', $valuesTmp['tags']);
+
+ if ($this->hasNativeHex()) {
+ $this->addEntryPrepared->bindParam(':hash', $valuesTmp['hash']);
+ } else {
+ $valuesTmp['hashBin'] = pack('H*', $valuesTmp['hash']); //hex2bin() is PHP5.4+
+ $this->addEntryPrepared->bindParam(':hash', $valuesTmp['hashBin']);
+ }
}
-
if ($this->addEntryPrepared && $this->addEntryPrepared->execute()) {
- return $this->bd->lastInsertId();
+ return true;
} else {
$info = $this->addEntryPrepared == null ? array(0 => '', 1 => '', 2 => 'syntax error') : $this->addEntryPrepared->errorInfo();
if ($this->autoUpdateDb($info)) {
+ $this->addEntryPrepared = null;
return $this->addEntry($valuesTmp);
- } elseif ((int)($info[0] / 1000) !== 23) { //Filter out "SQLSTATE Class code 23: Constraint Violation" because of expected duplicate entries
+ } elseif ((int)((int)$info[0] / 1000) !== 23) { //Filter out "SQLSTATE Class code 23: Constraint Violation" because of expected duplicate entries
Minz_Log::error('SQL error addEntry: ' . $info[0] . ': ' . $info[1] . ' ' . $info[2]
. ' while adding entry in feed ' . $valuesTmp['id_feed'] . ' with title: ' . $valuesTmp['title']);
}