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

twistor’s picture

Version: 6.x-1.x-dev » 7.x-2.x-dev
Assigned: Unassigned » twistor

Yup, 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.

bluegeek9’s picture

Assigned: twistor » Unassigned
Status: Active » Closed (outdated)
//www.flaticon.com/free-icons/thank-you Thank you for your contribution!

Unfortunately, Drupal 7 is End of Life and no longer supported. We strongly encourage you to upgrade to a supported version of Drupal.

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.