Parsing (in FeedsOPMLParser.inc, FeedsSimplePieParser.inc, FeedsSitemapParser.inc, FeedsSyndicationParser.inc) is ALWAYS performed, regardless of whether or not the raw data obtained from FeedsImportBatch::getRaw is cached or not.
Rather then have getRaw() return $result->data, can it return the entire $result object so that the parser can inspect $result->from_cache and do nothing if the raw data hasn't changed?
i.e.
// === FeedsHTTPFetcher optimized subclass. ===
/**
* Override of FeedsHTTPImportBatch::getRaw();
* Modified to return ENTIRE result object.
*/
public function getRaw() {
feeds_include_library('http_request.inc', 'http_request');
$result = http_request_get($this->url);
if (!in_array($result->code, array(200, 201, 202, 203, 204, 205, 206))) {
throw new Exception(t('Download of @url failed with code !code.', array('@url' => $this->url, '!code' => $result->code)));
}
return $result; // changed from $result->data
}
...
// === FeedsSimplePieParser subclass. ===
public function parse(FeedsImportBatch $batch, FeedsSource $source) {
feeds_include_library('simplepie.inc', 'simplepie');
$msg = "Parsing: {$batch->getURL()}";
$batchData = $batch->getRaw();
// If 304, then this data has already been parsed
if ($batchData->from_cache) {
$msg .= ' (parsing bypassed - cache detected)';
drupal_set_message($msg);
return;
}
drupal_set_message($msg);
...
Comments
Comment #1
twistor commentedYup, I've been thinking about this for a while. It's very annoying that this can't be handled in FeedsHTTPFetcher. The parser shouldn't have to know about these things.
Comment #2
bluegeek9 commentedUnfortunately, Drupal 7 is End of Life and no longer supported. We strongly encourage you to upgrade to a supported version of Drupal.