Moodle

RSS Redirects fail because of Snoopy's addition of :80 to URIs.

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Minor Minor
  • Resolution: Fixed
  • Affects Version/s: 1.8, 1.8.1, 1.8.2
  • Fix Version/s: 1.9
  • Component/s: RSS
  • Labels:
    None
  • Environment:
    Moodle 1.8.1,

Description

During our various Moodle workshops this summer, we've had the RSS feed block in Moodle fail on some, but not all, RSS feeds. The most prominent of these failures occurred with the BBC and Wall Street Journal feeds. When the failure occurs, Moodle says there was a problem fetching the feed, and that you should check it before using it in a block.

If you didn't specify a title, the feed you added ends up being title-less, and can not be added to an RSS block.

The problem lurks deep within the innards of Moodle, with the Snoopy object class that Magpie RSS uses to fetch URIs (Moodle in turn uses Magpie to parse the fetched RSS).

The problem is that Snoopy (found in htdocs/lib/snoopy/Snoopy.class.inc) is indiscriminately adding a ":80" to all the URIs that it processes. For many sites this is not a problem, as the regular address and the one with :80 specified end up being the same. For others, it is.

Case in point, the Wall Street Journal.

The Wall Street Journal's RSS feeds (as of this writing) redirect to another RSS feed when you try to subscribe them. So this feed for "What's News"

http://online.wsj.com/xml/rss/3_7011.xml

ends up redirecting to this feed:

http://feeds.wsjonline.com/wsj/xml/rss/3_7011.xml

However, if you add a :80 to the original url (resulting in http://online.wsj.com:80/xml/rss/3_7011.xml) you end up getting redirected to the WSJ journal home page...

http://online.wsj.com/public/us

...which causes Magpie to return a 302 redirection error because Snoopy's not able to follow the redirect to its true destination. This ultimately causes web apps that rely on Magpie to parse RSS (like Moodle) to fail on what appears to be a perfectly OK RSS feed.

Feed2JS (http://www.feed2js.org) would have the same problem, except its using a slightly older version of Snoopy that doesn't have this Port 80 logic included.

<a href="http://sourceforge.net/tracker/index.php?func=detail&aid=1671104&group_id=2091&atid=102091">This bug report on SourceForge outlines the problem</a>.

<a href="http://trac.wordpress.org/ticket/3993">A good solution was posted to the Wordpress bug tracker</a>, which suggests changing the following code on line 799 of Snoopy.class.inc from:

if(!empty($this->port))
$headers .= ":".$this->port;

to:

if(!empty($this->port))
if ($this->port != 80) {
$headers .= ":".$this->port;
}

This causes Snoopy to be more discriminate, only adding in the port when it's not :80. While this is technically a Snoopy problem rather than a Moodle one, it does occur in code that's part of the Moodle download.

In addition, Moodle's RSS block has trouble evaluating the response from Magpie, which reports a 302 redirection error for the troublesome RSS feed. Moodle ignores this specific response, and instead gives a more generic one saying there was a problem parsing the feed. It then allows this non-feed to be added to the user's RSS library anyway. If you didn't specify a title for the feed, then it shows up blank in the list of available feeds under "configure this block".

Given that no valid feed is returned from Magpie, I think it would be better if Moodle said the addition of the feed failed because of a broken redirect (or something to that effect). Fixing the underlying Snoopy problem should render this point moot, but in any case I think Moodle should simply prevent feeds with error codes from being added.

Issue Links

Activity

Hide
Mohammad Ehtesham added a comment -

I tried this by altering the Snoopy.class.inc file;

if(!empty($this->port))
$headers .= ":".$this->port;

to:

if(!empty($this->port))
if ($this->port != 80) {
$headers .= ":".$this->port;
}

But it is not working.
My feeling is that this problem is due to proxy internet connection. I have checked the settings on the direct intenet connection system where the RSS feed is working fine.
Can you suggest me any thing what I need to do in this regard.

Show
Mohammad Ehtesham added a comment - I tried this by altering the Snoopy.class.inc file; if(!empty($this->port)) $headers .= ":".$this->port; to: if(!empty($this->port)) if ($this->port != 80) { $headers .= ":".$this->port; } But it is not working. My feeling is that this problem is due to proxy internet connection. I have checked the settings on the direct intenet connection system where the RSS feed is working fine. Can you suggest me any thing what I need to do in this regard.
Hide
Kenneth Newquist added a comment -

My understanding from talking with one of our librarians versed in this sort of thing is that, for whatever reason, proxied RSS feeds usually fail when subscribed to via a feed reader. He didn't know why, but that was his experience; his recommendation was to always use the unproxied feed.

Show
Kenneth Newquist added a comment - My understanding from talking with one of our librarians versed in this sort of thing is that, for whatever reason, proxied RSS feeds usually fail when subscribed to via a feed reader. He didn't know why, but that was his experience; his recommendation was to always use the unproxied feed.
Hide
Petr Škoda (skodak) added a comment -

I hope this is fixed now in latest 1.9dev when cURL installed, please note that it is highly recommended to install cURL PHP extension which is used instead of snoopy if present.
thanks for the report

Show
Petr Škoda (skodak) added a comment - I hope this is fixed now in latest 1.9dev when cURL installed, please note that it is highly recommended to install cURL PHP extension which is used instead of snoopy if present. thanks for the report
Hide
Andrew Davis added a comment -

RSS feeds are working in both 1.9 and 2. Im using the cURL PHP extension. Closing.

Show
Andrew Davis added a comment - RSS feeds are working in both 1.9 and 2. Im using the cURL PHP extension. Closing.

People

Dates

  • Created:
    Updated:
    Resolved: