If a feed is not parseable Aggregator gives a parse error and then another "feed not parseable" error. "feed not parseable" error is unnecessary. Attached patch eliminates "feed not parseable" error.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Dries’s picture

Version: 7.x-dev » 6.x-dev
Status: Needs review » Needs work

Thanks M. I've committed this patch to CVS HEAD (Drupal 7). It failed to apply against DRUPAL-6 though so I'm changing the version number.

mustafau’s picture

Status: Needs work » Needs review
FileSize
1.12 KB

This patch applies to DRUPAL-6.

domesticat’s picture

I'm hesitant to mark this patch RTBC because I'm a patchtest noob, but this one seems to be a no-brainer. I've tested it against D6. It eliminated the double reporting of feed errors in my logs and I've seen no further issues.

StevenPatz’s picture

Status: Needs review » Reviewed & tested by the community
Gábor Hojtsy’s picture

Version: 6.x-dev » 7.x-dev
Status: Reviewed & tested by the community » Needs work

Hm. Before the patch, the code structure is as follows:

  Do drupal_http_request
  switch (on result code) {
    if 304: no new content. always break!
    if 301: record new url and fall over!
    if 200, 302 or 307: try to parse and if not possible, fall over; if possible, break!
    otherwise: report error;
  }

So this ensures that if there is a new URL, or there was some response, but the data was not parseable, there is an error reported. Also, it reports an error, if the status code is other then 304, 301, 200, 302 and 307. For example, if the code is a 404.

From the patch, I see, it moved the break around, so what it does is:

  Do drupal_http_request
  switch (on result code) {
    if 304: no new content. always break!
    if 301: record new url and fall over!
    if 200, 302 or 307: try to parse; <strong>always break!</strong>
    otherwise: report error;
  }

Looks, I've emphasized your change. So this breaks the cycle of possibly parsing data when the feed was a 301 redirect, which was the intention of the original code. Also, as far as I see, it breaks reporting errors when there was a 200, 302 or 307 but the feed was not parseable.

I assume I might understand something wrong, since you clearly state that the patch makes one of two error messages appear. You don't hovewer present examples of those two error messages, and the one which still appears. So what I can see from here, is that you stepped over error reporting in many cases with this patch. But where is that actual error reporting done now I don't see; drupal_http_request() does not do error reporting itself and this aggregator_refresh() function is called from aggregator_cron() which does not care about any return values or errors produced inside aggregator_refresh().

mustafau’s picture

aggregator_parse_feed() reports the error.

The structure is like following:

Before:

Do drupal_http_request()
switch (on result code) {
  if 304: no new content. always break!
  if 301: record new url and fall over!
  if 200, 302 or 307: try to parse and if not possible, report error (aggregator_parse_feed()) and fall over; if possible, break!
  otherwise: report error;
}

After:

Do drupal_http_request()
switch (on result code) {
  if 304: no new content. always break!
  if 301: record new url and fall over!
  if 200, 302 or 307: try to parse and if not possible, report error (aggregator_parse_feed()); <strong>always break!</strong>
  otherwise: report error;
}

301 redirects are not affected from the change. Parse errors are reported by aggregator_parse_feed(). Other errors are reported by the "default" case of the switch statement.

mustafau’s picture

Status: Needs work » Reviewed & tested by the community

Status: Reviewed & tested by the community » Needs work

The last submitted patch failed testing.

mustafau’s picture

Version: 7.x-dev » 6.x-dev
Status: Needs work » Reviewed & tested by the community
Gábor Hojtsy’s picture

Status: Reviewed & tested by the community » Fixed

Right, I've reviewed the patch again, and it looked like doing what it is advertised to do :) Committed.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.