diff options
author | Dries Buytaert <dries@buytaert.net> | 2002-01-05 21:48:14 +0000 |
---|---|---|
committer | Dries Buytaert <dries@buytaert.net> | 2002-01-05 21:48:14 +0000 |
commit | a17812ccdb97683560ae8614b4ac65ff456c4cec (patch) | |
tree | 40ea2e3beca8dfed18b99e152ce7d1d1ed8b9de1 /modules/aggregator | |
parent | 09d054a4f4d1e821acae4103d188c9c045f1e7be (diff) | |
download | brdo-a17812ccdb97683560ae8614b4ac65ff456c4cec.tar.gz brdo-a17812ccdb97683560ae8614b4ac65ff456c4cec.tar.bz2 |
- Improved the feed handling which solves "almost duplicate" posts being
inserted when someone would update his site/feed after we imported it.
Diffstat (limited to 'modules/aggregator')
-rw-r--r-- | modules/aggregator/aggregator.module | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/modules/aggregator/aggregator.module b/modules/aggregator/aggregator.module index da1662641..cee9bf2e3 100644 --- a/modules/aggregator/aggregator.module +++ b/modules/aggregator/aggregator.module @@ -208,10 +208,19 @@ function import_refresh($feed) { // print "<pre>title = ". htmlentities($title) ."\n\ndescription = ". htmlentities($description) ."\n\nlink = ". htmlentities($link) ."</pre><hr />"; /* - ** Save this item: + ** Save this item. Try to avoid duplicate entries as much as + ** possible. If we find a duplicate entry, we resolve it and + ** pass along its ID such that we can update it (when needed). */ - import_save_item(array(fid => $feed["fid"], title => $title, link => $link, author => $author, description => $description, attributes => $feed["attributes"])); + if ($link && $link != $feed["link"] && $link != $feed["url"]) { + $entry = db_fetch_object(db_query("SELECT iid FROM item WHERE fid = '". check_query($feed["fid"]) ."' AND link = '". check_query($link) ."'")); + } + else { + $entry = db_fetch_object(db_query("SELECT iid FROM item WHERE fid = '". check_query($feed["fid"]) ."' AND title = '". check_query($title) ."'")); + } + + import_save_item(array(iid => $entry->iid, fid => $feed["fid"], title => $title, link => $link, author => $author, description => $description, attributes => $feed["attributes"])); } } @@ -247,9 +256,7 @@ function import_save_item($edit) { db_query("DELETE FROM item WHERE iid = '". check_input($edit["iid"]) ."'"); } else if ($edit["title"] && $edit["link"]) { - if (!db_fetch_object(db_query("SELECT iid FROM item WHERE title = '". check_input($edit["title"]) ."' AND link = '". check_input($edit["link"]) ."' AND description = '". check_input($edit["description"]) ."'"))) { - db_query("INSERT INTO item (fid, title, link, author, description, attributes, timestamp) VALUES ('". check_input($edit["fid"]) ."', '". check_input($edit["title"]) ."', '". check_input($edit["link"]) ."', '". check_input($edit["author"]) ."', '". check_input($edit["description"]) ."', '". check_input($edit["attributes"]) ."', '". time() ."')"); - } + db_query("INSERT INTO item (fid, title, link, author, description, attributes, timestamp) VALUES ('". check_input($edit["fid"]) ."', '". check_input($edit["title"]) ."', '". check_input($edit["link"]) ."', '". check_input($edit["author"]) ."', '". check_input($edit["description"]) ."', '". check_input($edit["attributes"]) ."', '". time() ."')"); } } |