Feedvalidator.org reports this warning when validating a Drupal site's RSS feed:

Missing atom:link with rel="self"

The explanation says that the channel section requires an atom link to the feed, and also the Atom namespace declaration.

Comments

mgifford’s picture

Version: 6.x-dev » 7.x-dev
Status: Active » Needs review
StatusFileSize
new1.51 KB

I got the same thing with Drupal 7. Decided it was time to figure out why and resolve the problem. Just added a atom name space.

Related links:
http://www.rssboard.org/rss-profile-1#namespace-elements-atom-link
http://validator.w3.org/feed/docs/howto/declare_namespaces.html
http://wordpress.org/support/topic/144264?replies=11

dave reid’s picture

Title: RSS validation warning » Add missing atom:link with rel="self" to RSS feeds
Issue tags: +RSS

It's worth noting this is just a recommendation, not a warning.
See http://feedvalidator.org/check.cgi?url=http%3A%2F%2Fdrupal.org

mgifford’s picture

Very true, but it's annoying and it looks bad. Why not just fix it up properly by adding full support for the atom name space?

Especially since wordpress seems to already be supporting the following name spaces in their rss feeds:

xmlns:content="http://purl.org/rss/1.0/modules/content/"
xmlns:wfw="http://wellformedweb.org/CommentAPI/"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:atom="http://www.w3.org/2005/Atom"
xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"

Status: Needs review » Needs work

The last submitted patch failed testing.

mgifford’s picture

Think the 9 exceptions are just changes to the simpletest definitions... Could be wrong though.

jhl.verona’s picture

Version: 7.x-dev » 6.17
Status: Needs work » Reviewed & tested by the community
StatusFileSize
new1.78 KB

The original patch by mgifford has an error: the modification to format_rss_channel uses $base_url but fails to declare it as a global. Also (same function) I changed the default URL for $self_file from 'rss.xml' to '/rss.xml'

Unfortunately I don't have a Drupal 7 codebase, so I am attaching a patch against Drupal 6.17. This has been 'tested' on the Drupal Italia forums, here http://www.drupalitalia.org/node/10879 (which is why I've set 'reviewed and tested by the community), in particular by Giovanni Di Giovanni on his web site: http://giovanninews.com/taxonomy/term/7/0/feed for example, which gives http://feedvalidator.org/check.cgi?url=http%3A%2F%2Fgiovanninews.com%2Ft...

Many thanks to mgifford for the original patch, I hope he can use this to repatch Drupal 7.

John

dave reid’s picture

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

This needs to be fixed in D7 first, then backported if necessary. That's just the way this works, so please don't change the version again.

+++ includes/common.inc	14 Jun 2010 17:05:23 -0000
@@ -1065,11 +1065,13 @@ function check_url($uri) {
+  $self_file = (!empty($_SERVER['REQUEST_URI'])) ? $_SERVER['REQUEST_URI']  : '/rss.xml';

Why can't we use $_GET['q'] instead?

+++ includes/common.inc	14 Jun 2010 17:05:23 -0000
@@ -1065,11 +1065,13 @@ function check_url($uri) {
+  $output .= ' <atom:link href="' . $base_url . $self_file . "\" rel=\"self\" type=\"application/rss+xml\" />\n";

Other functions use format_rss_channel and will need to have the xmlns:atom added to their tag output in order to validate.
See http://api.drupal.org/api/function/theme_aggregator_page_rss/7

+++ modules/node/node.module	14 Jun 2010 17:05:26 -0000
@@ -1665,7 +1665,7 @@ function node_feed($nids = FALSE, $chann
+  $namespaces = array('xmlns:dc' => 'http://purl.org/dc/elements/1.1/', 'xmlns:atom' => 'http://www.w3.org/2005/Atom');

Arrays longer than 80 characters should have each element on a new line.

66 critical left. Go review some!

jhl.verona’s picture

StatusFileSize
new1.6 KB

This needs to be fixed in D7 first, then backported if necessary. That's just the way this works, so please don't change the version again.

My apologies.

Why can't we use $_GET['q'] instead?

Perhaps mgifford can reply as to why he used $_SERVER['REQUEST_URI'], though thinking about it, even the test (and hence local variable $self_file) seems superfluous to me.

Other functions use format_rss_channel and will need to have the xmlns:atom added to their tag output in order to validate.

Ah - theme_aggregator_page_rss(). Excellent observation - I see what you mean. Obviously this can be patched as well, but unfortunately, the format_rss_channel() function is used by a great many contributed modules, and each or all of them can be setting their own rss element.

At this point, as far as Drupal core is concerned, IMHO it would make sense to add a format_rss_body() function so that there is only one way of creating the rss element. Though this is not essential, just a "nice to have".

Fortunately, format_rss_channel() provides an args parameter, which doesn't seem to be used by any contributed module (in Drupal 6.x, doing a quick grep, and no, I'm not prepared to bet money on it). This is, it would appear, the 'correct' way of adding additional elements to the channel, so the problem can be circumvented by adding the element, not in format_rss_channel(), but in node_feed() itself. The RSS board does not seem to specify exactly where the atom:link element should be placed (http://www.rssboard.org/rss-profile) just that item elements come last.
So the patch could be something like:

  $channel_defaults = array(
    'version'     => '2.0',
    'title'       => variable_get('site_name', 'Drupal'),
    'link'        => $base_url,
    'description' => variable_get('site_mission', ''),
    'language'    => $language->language
  );
  $channel = array_merge($channel_defaults, $channel);

  $atom_link = array(
    'key'        => 'atom:link',
    'attributes' => array(
      'href' => $base_url .'/'. $_GET['q'],
      'rel'  => 'self',
      'type' => 'application/rss+xml',
    ),
  );

  $output = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n";
  $output .= "<rss version=\"". $channel["version"] ."\" xml:base=\"". $base_url ."\" ". drupal_attributes($namespaces) .">\n";
  $output .= format_rss_channel($channel['title'], $channel['link'], $channel['description'], $items, $channel['language'], array($atom_link));
  $output .= "</rss>\n";
Arrays longer than 80 characters should have each element on a new line.
  $namespaces = array(
    'xmlns:dc' => 'http://purl.org/dc/elements/1.1/',
    'xmlns:atom' => 'http://www.w3.org/2005/Atom',
  );

I have again attached a patch, as always for Drupal 6.17 (sorry), and I'm not going anywhere near the 'Edit issue settings' panel ;-)

HTH

John

jhl.verona’s picture

Status: Needs work » Needs review

Trying to kick in the automatic test for the patch, sorry.
It's just not my day today - I forgot this is Drupal 7 development. my apologies...

venusrising’s picture

Status: Needs review » Active

Anyone in #8 get this working test this? I see it si for 6 which is what we want we were just not sure if it is ready for testing? Please let us know

herve’s picture

subscribe.
No plan to apply a patch for D7 and D6 about this problem of atom:link?

Regards,

herve.

herve’s picture

At the moment, you should add atom:link attribute in that way

$args = array(
  array(
  'key' => 'atom:link',
  'attributes' => array('href' => $url, 'rel' => 'self', 'type' => 'application/rss+xml'),
  'value' => '')
 );
$channel = format_rss_channel('My Channel', $url,
                               'My channel description', $items,
                               'EN', $args);
venusrising’s picture

@hereve can you explain where this # 12 code would be added to? Thanks for your help

nig’s picture

Could anyone explain where to put the #12 code? I have built my RSS feed with Views module and I can't see anywhere in Views where this could go.

Thanks

nig’s picture

in case anyone else is struggling with this....

I ended up using the Views RSS module

GasmanDesign’s picture

Issue tags: +atom xml:base, +Views RSS

I'm trying to add this to my Drupal 6 RSS feed because I keep getting this error: Add missing atom:link with rel="self" to RSS feeds.

I noticed this code is at the top of D7 RSS feeds in the Channel.

What's the easiest way to add the "atom:link" to my RSS channel in Drupal 6?

Where does the PHP code from #12 (herve) go? Into the index.php file?

I tried installing the Views RSS module and adding it with views, but I can't seem to get the fields to show up.

Any info would be great.

The project: My client developed a Wordpress mobile app and has a Druapl 6 website. They are trying to use their RSS feeds to pull in News to their new app.

jp.stacey’s picture

Issue summary: View changes

For reference, this seems to be fixed in Views.

I'd implemented my own workaround for this unfixed issue using hook_preprocess_views_view_rss() some time ago, on my Planet Drupal feed. This uses Views, not core I'd not made any changes recently, but just today, the feed was reported as no longer passing RSS validation: https://www.drupal.org/node/2468977#comment-10719336

This was because the xmlns:atom attribute was being added twice. In effect, my own fix had become a duplication instead. Here's the fix to Views, included as part of 7.x-3.12 in November: #1337894: Views RSS feeds have a validation recommendation

So one workaround in the absence of a fix would be to use Views for the site's RSS. Not ideal, but an option.

neclimdul’s picture

Status: Active » Closed (duplicate)

Newer issue jp mentioned captures current state better and has more recent(hah!) activity so cleaning this up.

papagrande’s picture