aboutsummaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorGravatar Alexandre Alapetite <alexandre@alapetite.fr> 2013-11-26 23:52:53 +0100
committerGravatar Alexandre Alapetite <alexandre@alapetite.fr> 2013-11-26 23:53:22 +0100
commit6130ba6157fc214579a0466ec122a8f085224415 (patch)
treeb095eedbf8b6c891c803b9487ce3e36552e73dd7 /app
parentb703099c1947d26764a8e936ecb9ea58e15fbd63 (diff)
SQL : utilisation de (id_feed, guid) pour l'unicité
Préparation avant https://github.com/marienfressinaud/FreshRSS/issues/202
Diffstat (limited to 'app')
-rwxr-xr-xapp/controllers/feedController.php15
-rwxr-xr-xapp/models/Entry.php6
-rw-r--r--app/models/Feed.php2
3 files changed, 10 insertions, 13 deletions
diff --git a/app/controllers/feedController.php b/app/controllers/feedController.php
index 9ce38a03f..174cd9519 100755
--- a/app/controllers/feedController.php
+++ b/app/controllers/feedController.php
@@ -174,17 +174,14 @@ class feedController extends ActionController {
$feed->load ();
$entries = $feed->entries ();
- //For this feed, check last n entry IDs already in database
- $existingIds = array_fill_keys ($entryDAO->listLastIdsByFeed ($feed->id (), count($entries) + 10), 1);
-
- // ajout des articles en masse sans se soucier des erreurs
- // On ne vérifie pas que l'article n'est pas déjà en BDD
- // car demanderait plus de ressources
- // La BDD refusera l'ajout de son côté car l'id doit être
- // unique
+ //For this feed, check last n entry GUIDs already in database
+ $existingGuids = array_fill_keys ($entryDAO->listLastGuidsByFeed ($feed->id (), count($entries) + 10), 1);
+
+ // On ne vérifie strictement que l'article n'est pas déjà en BDD
+ // La BDD refusera l'ajout car (id_feed, guid) doit être unique
$feedDAO->beginTransaction ();
foreach ($entries as $entry) {
- if ((!isset ($existingIds[$entry->id ()])) &&
+ if ((!isset ($existingGuids[$entry->guid ()])) &&
($entry->date (true) >= $date_min ||
$feed->keepHistory ())) {
$values = $entry->toArray ();
diff --git a/app/models/Entry.php b/app/models/Entry.php
index e2493e266..abf381a9b 100755
--- a/app/models/Entry.php
+++ b/app/models/Entry.php
@@ -565,9 +565,9 @@ class EntryDAO extends Model_pdo {
public function listByFeed ($feed, $state, $order = 'high_to_low', $limitFromId = '', $limitCount = '') {
return $this->listWhere (' WHERE id_feed = ?', $state, $order, $limitFromId, $limitCount, array ($feed));
}
-
- public function listLastIdsByFeed($id, $n) {
- $sql = 'SELECT id FROM ' . $this->prefix . 'entry WHERE id_feed=? ORDER BY date DESC LIMIT ' . intval($n);
+
+ public function listLastGuidsByFeed($id, $n) {
+ $sql = 'SELECT guid FROM ' . $this->prefix . 'entry WHERE id_feed=? ORDER BY date DESC LIMIT ' . intval($n);
$stm = $this->bd->prepare ($sql);
$values = array ($id);
$stm->execute ($values);
diff --git a/app/models/Feed.php b/app/models/Feed.php
index 822f6e703..d1d85d838 100644
--- a/app/models/Feed.php
+++ b/app/models/Feed.php
@@ -191,7 +191,7 @@ class Feed extends Model {
} else {
$feed = new SimplePie ();
$feed->set_useragent(Translate::t ('freshrss') . '/' . FRESHRSS_VERSION . ' (' . PHP_OS . '; ' . FRESHRSS_WEBSITE . ') ' . SIMPLEPIE_NAME . '/' . SIMPLEPIE_VERSION);
- $url = str_replace ('&amp;', '&', $this->url);
+ $url = htmlspecialchars_decode ($this->url, ENT_QUOTES);
if ($this->httpAuth != '') {
$url = preg_replace ('#((.+)://)(.+)#', '${1}' . $this->httpAuth . '@${3}', $url);
}