summaryrefslogtreecommitdiff
path: root/modules/aggregator
diff options
context:
space:
mode:
authorDries Buytaert <dries@buytaert.net>2010-01-08 11:03:54 +0000
committerDries Buytaert <dries@buytaert.net>2010-01-08 11:03:54 +0000
commitafbcbefa85fd6fb497f33c6d4a151e96e377b9b4 (patch)
tree2664234a5e66aa4a4043dc9fdcf1d7449c60889c /modules/aggregator
parent4b8ba4fa2cd2a5767a81831c3ce7467d256b823c (diff)
downloadbrdo-afbcbefa85fd6fb497f33c6d4a151e96e377b9b4.tar.gz
brdo-afbcbefa85fd6fb497f33c6d4a151e96e377b9b4.tar.bz2
- Patch #564686 by mustafau, alex_b: fetcher should not update aggregator_feed() record.
Diffstat (limited to 'modules/aggregator')
-rw-r--r--modules/aggregator/aggregator.api.php13
-rw-r--r--modules/aggregator/aggregator.fetcher.inc20
-rw-r--r--modules/aggregator/aggregator.module19
3 files changed, 26 insertions, 26 deletions
diff --git a/modules/aggregator/aggregator.api.php b/modules/aggregator/aggregator.api.php
index 5fc07778d..cfdac8f16 100644
--- a/modules/aggregator/aggregator.api.php
+++ b/modules/aggregator/aggregator.api.php
@@ -28,6 +28,9 @@
* $feed->url contains the link to the feed. Download the data at the URL
* and expose it to other modules by attaching it to $feed->source_string.
*
+ * @return
+ * TRUE if fetching was successful, FALSE otherwise.
+ *
* @see hook_aggregator_fetch_info()
* @see hook_aggregator_parse()
* @see hook_aggregator_process()
@@ -82,12 +85,12 @@ function hook_aggregator_fetch_info() {
* $feed->source_string contains the raw feed data as a string. Parse data
* from $feed->source_string and expose it to other modules as an array of
* data items on $feed->items.
- *
+ *
* Feed format:
* - $feed->description (string) - description of the feed
* - $feed->image (string) - image for the feed
* - $feed->etag (string) - value of feed's entity tag header field
- * - $feed->modified (UNIX timestamp) - value of feed's last modified header
+ * - $feed->modified (UNIX timestamp) - value of feed's last modified header
* field
* - $feed->items (Array) - array of feed items.
*
@@ -101,8 +104,8 @@ function hook_aggregator_fetch_info() {
* AUTHOR (string) - the feed item's author
* GUID (string) - RSS/Atom global unique identifier
* LINK (string) - the feed item's URL
- *
- * @return
+ *
+ * @return
* TRUE if parsing was successful, FALSE otherwise.
*
* @see hook_aggregator_parse_info()
@@ -116,7 +119,7 @@ function hook_aggregator_parse($feed) {
$feed->items = $items;
return TRUE;
}
- return FALSE;
+ return FALSE;
}
/**
diff --git a/modules/aggregator/aggregator.fetcher.inc b/modules/aggregator/aggregator.fetcher.inc
index 7c697052c..0974a6926 100644
--- a/modules/aggregator/aggregator.fetcher.inc
+++ b/modules/aggregator/aggregator.fetcher.inc
@@ -37,11 +37,6 @@ function aggregator_aggregator_fetch($feed) {
// Process HTTP response code.
switch ($result->code) {
case 304:
- db_update('aggregator_feed')
- ->fields(array('checked' => REQUEST_TIME))
- ->condition('fid', $feed->fid)
- ->execute();
- drupal_set_message(t('There is no new syndicated content from %site.', array('%site' => $feed->title)));
break;
case 301:
$feed->url = $result->redirect_url;
@@ -49,25 +44,12 @@ function aggregator_aggregator_fetch($feed) {
case 200:
case 302:
case 307:
- // We store the md5 hash of feed data in the database. When refreshing a
- // feed we compare stored hash and new hash calculated from downloaded
- // data. If both are equal we say that feed is not updated.
if (!isset($result->data)) {
$result->data = '';
}
if (!isset($result->headers)) {
$result->headers = array();
}
- $md5 = md5($result->data);
- if ($feed->hash == $md5) {
- db_update('aggregator_feed')
- ->condition('fid', $feed->fid)
- ->fields(array('checked' => REQUEST_TIME))
- ->execute();
- drupal_set_message(t('There is no new syndicated content from %site.', array('%site' => $feed->title)));
- break;
- }
-
$feed->source_string = $result->data;
$feed->http_headers = $result->headers;
break;
@@ -75,4 +57,6 @@ function aggregator_aggregator_fetch($feed) {
watchdog('aggregator', 'The feed from %site seems to be broken, due to "%error".', array('%site' => $feed->title, '%error' => $result->code . ' ' . $result->error), WATCHDOG_WARNING);
drupal_set_message(t('The feed from %site seems to be broken, because of error "%error".', array('%site' => $feed->title, '%error' => $result->code . ' ' . $result->error)));
}
+
+ return $feed->source_string === FALSE ? FALSE : TRUE;
}
diff --git a/modules/aggregator/aggregator.module b/modules/aggregator/aggregator.module
index 44290d19f..3812ed3c9 100644
--- a/modules/aggregator/aggregator.module
+++ b/modules/aggregator/aggregator.module
@@ -599,9 +599,14 @@ function aggregator_refresh($feed) {
// Fetch the feed.
list($fetcher, $parser, $processors) = _aggregator_get_variables();
- module_invoke($fetcher, 'aggregator_fetch', $feed);
+ $success = module_invoke($fetcher, 'aggregator_fetch', $feed);
- if ($feed->source_string !== FALSE) {
+ // We store the md5 hash of feed data in the database. When refreshing a
+ // feed we compare stored hash and new hash calculated from downloaded
+ // data. If both are equal we say that feed is not updated.
+ $md5 = md5($feed->source_string);
+
+ if ($success && ($feed->hash != $md5)) {
// Parse the feed.
if (module_invoke($parser, 'aggregator_parse', $feed)) {
// Update feed with parsed data.
@@ -613,7 +618,7 @@ function aggregator_refresh($feed) {
'link' => empty($feed->link) ? $feed->url : $feed->link,
'description' => empty($feed->description) ? '' : $feed->description,
'image' => empty($feed->image) ? '' : $feed->image,
- 'hash' => md5($feed->source_string),
+ 'hash' => $md5,
'etag' => empty($feed->etag) ? '' : $feed->etag,
'modified' => empty($feed->modified) ? 0 : $feed->modified,
))
@@ -636,6 +641,14 @@ function aggregator_refresh($feed) {
}
}
}
+ else {
+ db_update('aggregator_feed')
+ ->fields(array('checked' => REQUEST_TIME))
+ ->condition('fid', $feed->fid)
+ ->execute();
+
+ drupal_set_message(t('There is no new syndicated content from %site.', array('%site' => $feed->title)));
+ }
// Expire old feed items.
if (function_exists('aggregator_expire')) {