Commit 2f4d6e31 authored by Kjartan's avatar Kjartan

- Fixed pruning of old items giving errors when there are no old items.

parent cd850119
......@@ -296,10 +296,7 @@ function aggregator_refresh($feed) {
case 302:
case 307:
// Filter the input data:
if (!valid_input_data($result->data)) {
drupal_set_message(t('failed to parse RSS feed "%site": suspicious input data.', array('%site' => $feed['title'])), 'error');
}
else if (aggregator_parse_feed($result->data, $feed)) {
if (aggregator_parse_feed($result->data, $feed)) {
if ($result->headers['Last-Modified']) {
$modified = strtotime($result->headers['Last-Modified']);
......@@ -454,7 +451,12 @@ function aggregator_parse_feed(&$data, $feed) {
$entry = db_fetch_object(db_query("SELECT iid FROM {aggregator_item} WHERE fid = %d AND title = '%s'", $feed['fid'], $title));
}
aggregator_save_item(array('iid' => $entry->iid, 'fid' => $feed['fid'], 'timestamp' => $timestamp, 'title' => $title, 'link' => $link, 'author' => $item['AUTHOR'], 'description' => $item['DESCRIPTION']));
if (!valid_input_data($item['DESCRIPTION'])) {
drupal_set_message(t('failed to parse entry from "%site" feed: suspicious input data.', array('%site' => $feed['title'])), 'error');
}
else {
aggregator_save_item(array('iid' => $entry->iid, 'fid' => $feed['fid'], 'timestamp' => $timestamp, 'title' => $title, 'link' => $link, 'author' => $item['AUTHOR'], 'description' => $item['DESCRIPTION']));
}
}
/*
......@@ -464,13 +466,14 @@ function aggregator_parse_feed(&$data, $feed) {
$age = time() - 1209600; // 3 month
$result = db_query('SELECT iid FROM {aggregator_item} WHERE fid = %d AND timestamp < %d', $feed['fid'], $age);
$items = array();
while ($item = db_fetch_object($result)) {
$items[] = "iid = '$item->iid'";
if (db_num_rows($result)) {
$items = array();
while ($item = db_fetch_object($result)) {
$items[] = $item->iid;
}
db_query('DELETE FROM {aggregator_category_item} WHERE iid IN ('. implode(', ', $items) .')');
db_query('DELETE FROM {aggregator_item} WHERE fid = %d AND timestamp < %d', $feed['fid'], $age);
}
$where = implode(' OR ', $items);
db_query('DELETE FROM {aggregator_category_item} WHERE '. implode(' OR ', $items));
db_query('DELETE FROM {aggregator_item} WHERE fid = %d AND timestamp < %d', $feed['fid'], $age);
return 1;
}
......
......@@ -296,10 +296,7 @@ function aggregator_refresh($feed) {
case 302:
case 307:
// Filter the input data:
if (!valid_input_data($result->data)) {
drupal_set_message(t('failed to parse RSS feed "%site": suspicious input data.', array('%site' => $feed['title'])), 'error');
}
else if (aggregator_parse_feed($result->data, $feed)) {
if (aggregator_parse_feed($result->data, $feed)) {
if ($result->headers['Last-Modified']) {
$modified = strtotime($result->headers['Last-Modified']);
......@@ -454,7 +451,12 @@ function aggregator_parse_feed(&$data, $feed) {
$entry = db_fetch_object(db_query("SELECT iid FROM {aggregator_item} WHERE fid = %d AND title = '%s'", $feed['fid'], $title));
}
aggregator_save_item(array('iid' => $entry->iid, 'fid' => $feed['fid'], 'timestamp' => $timestamp, 'title' => $title, 'link' => $link, 'author' => $item['AUTHOR'], 'description' => $item['DESCRIPTION']));
if (!valid_input_data($item['DESCRIPTION'])) {
drupal_set_message(t('failed to parse entry from "%site" feed: suspicious input data.', array('%site' => $feed['title'])), 'error');
}
else {
aggregator_save_item(array('iid' => $entry->iid, 'fid' => $feed['fid'], 'timestamp' => $timestamp, 'title' => $title, 'link' => $link, 'author' => $item['AUTHOR'], 'description' => $item['DESCRIPTION']));
}
}
/*
......@@ -464,13 +466,14 @@ function aggregator_parse_feed(&$data, $feed) {
$age = time() - 1209600; // 3 month
$result = db_query('SELECT iid FROM {aggregator_item} WHERE fid = %d AND timestamp < %d', $feed['fid'], $age);
$items = array();
while ($item = db_fetch_object($result)) {
$items[] = "iid = '$item->iid'";
if (db_num_rows($result)) {
$items = array();
while ($item = db_fetch_object($result)) {
$items[] = $item->iid;
}
db_query('DELETE FROM {aggregator_category_item} WHERE iid IN ('. implode(', ', $items) .')');
db_query('DELETE FROM {aggregator_item} WHERE fid = %d AND timestamp < %d', $feed['fid'], $age);
}
$where = implode(' OR ', $items);
db_query('DELETE FROM {aggregator_category_item} WHERE '. implode(' OR ', $items));
db_query('DELETE FROM {aggregator_item} WHERE fid = %d AND timestamp < %d', $feed['fid'], $age);
return 1;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment