Closed (fixed)
Project:
Feeds
Version:
7.x-2.x-dev
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
16 Sep 2011 at 12:45 UTC
Updated:
26 Nov 2016 at 08:34 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
natew commentedI have an atom 1.0 feed and I am using feeds to create nodes with the content. When I import from this feed all the imported links go to pages that do not exist. After a little investigation into the feed all the entry links are relative and use the rel="alternate" attribute.
I looked into the code for the Atom 1.0 Common syndication parser. it looks like there is code for handling the rel="alternate" links however the base path was not being set for me. The base path in my feed is in one of the link elements in the feed element (again with rel="alternate"). Attached is a patch that sets the base path (if not already set) to the href in the feed link with rel="alternate". This fixed my issue, however I am not sure if this is the correct approach or I am missing something?
Comment #2
natew commentedComment #3
natew commentedComment #5
twistor commentedComment #7
twistor commentedCan you share the link to this feed?
Comment #8
natew commentedSure, this is the feed in question.: http://www.jobbank.gc.ca/jobSearchRSS.do?pcd=YT&wid=pv&sort=D
Comment #9
megachrizI checked the feed with my Feeds import preview module. This is a preview of the parsed result using the common syndication parser on the latest dev:

The item's
<link rel="alternate">is parsed to the source "url". It looks like the issue here is that the url is taking "literally", the parsed result for url is for example:jobposting.do?pcd=YT&wid=pv&sort=D&id=17385559&source=rss, thus without a leading "http://www.example.com", which makes the url not very useful when it is displayed just like that. Am I right that is what the issue is about?Comment #10
natew commentedYeap, that is exactly the issue I ran into. Thank you for looking into this.
Comment #11
twistor commentedI'm not sure about this. Here's a patch, since current link handling is a bit broken, this patch makes a few more changes.
That said, this feed is broken, so it's not really a bug. The rel="alternate" is not supposed to be used as a base url. If anything, it should be the URL we downloaded the feed from, but since we don't have that, the rel="self" should be used.
Comment #12
natew commentedI reverted my patch from #1 and applied your patch from #11 on the alpha 8 release of feeds and the feed items don't seem to import. I went to the latest dev version (from yesterday) and verified the feed imports. I then applied the patch from #11 and recreated the feed. I got a while bunch of warnings.:
Serialization of 'SimpleXMLElement' is not allowed and a message that 75 items couldn't be imported.
Comment #13
twistor commentedProbably missed a string cast somewhere.
Comment #14
natew commentedThanks twistor, I just tried the latest patch and this works for me. The feed items get imported and the proper url is set.
I also wanted to mention that I agree about this feed being most likely broken. However the entries links do get parsed correctly and work in other "feed browsers" like firefox. So I think your solution will work. :)
Thanks again for looking into this and providing a solution!
Comment #15
natew commentedRe-spin the patch for feeds 7.x-2.0-beta2.
Comment #16
megachrizAnd now with an automated test! The first patch only includes the test and should fail. The second patch should pass tests. Let's see if that happens...
Note that I used content from this issue as test content :). You will be part of the history of Feeds, natew!
Comment #19
megachrizCommitted #16 with a small change in the following code:
Changed $new->content['src'] to $news->content['src'].