This patch add the guid (globally unique identifier) tag to the rss feed. This is in line with the RSS 2.0 Specification, se below. It's a very simpel, one line patch, to the format_rss_item function in common.inc.

I want this personally so my news reader (NetNewsWire) can distinguish between new and updates posts.

From http://blogs.law.harvard.edu/tech/rss

A frequently asked question about s is how do they compare to
s. Aren't they the same thing? Yes, in some content systems, and no in others. In some systems,
is a permalink to a weblog item. However, in other systems, each is a synopsis of a longer article,
points to the article, and is the permalink to the weblog entry. In all cases, it's recommended that you provide the guid, and if possible make it a permalink. This enables aggregators to not repeat items, even if there have been editing changes.

CommentFileSizeAuthor
#1 common_rss_guid_02.patch524 bytesfrjo
common_rss_guid.patch537 bytesfrjo
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

frjo’s picture

Version: 4.6.2 » x.y.z
Status: Active » Needs review
FileSize
524 bytes

I made a patch for the cvs version of Drupal also. I believe this is a smal but very nice improvement of Drupals RSS support.

Dries’s picture

guid has to be permanent. I don't think we can guarantuee that at the moment. People can set URL aliases and stuff, and these changes would change the guid.

Steven’s picture

Possible remedy: generate GUIDs by hashing the base url with the node id (optionally the word "node" too if we use this technique elsewhere).

Dries’s picture

Not quite. The problem is that $link is not necessarily unique (subject to change) as it can be aliased. foo.com/node/1 (non-aliased URL) is as unique as its hashed variant, and should be fairly unique (unless your are playing $base_url tricks). I think the solution is to pass a guid to format_rss_item() using the $args parameter.

Steven’s picture

I only meant those things: base URL, node ID and the word "node". Regardless of where it comes from. Perhaps we need a generic GUID generating mechanism. I chose the base URL as a unique "permanent" site-specific seed with the understanding that if your base URL changes, your feed location changes too and aggregators need to refresh anyway.

Damien Tournoud’s picture

An open question: in the RSS feed, should the urls be aliased ones or "base" (/node/#nid) ones?

I do think base ones are better, because they are permanent and reliable. RSS is meant for automated processes. URL aliases are meant for humans.

-- DamZ

frjo’s picture

Thanks for your intrest in this issue.

Could you do add a line like this to the node_feed function in node.module?

$extra = array_merge($extra, array(array('key' => 'guid', 'value' =>  $base_url .'/node/'. $node->nid)));

Just below the line where pubDate is added in the same manner.

This seems more complicated than adding a $guid argument to the format_rss_item function in common.inc but maybe it's a bad idé to go around changing functions that other modules can be using.

Damien Tournoud’s picture

I like the idea of building the guid from the $link. But for this to be consistant and permanent, we should use the "normal" node link, not the aliased one. So we must give an answer to my primary question.

-- DamZ

frjo’s picture

I believe the link tag should stay as it is, i.e. a standard Drupal URL with path alias if one is set.

The guid tag on the other hand need to be different as Dries stated, it must be a permanent URL. A URL with the format "base_url/node/nid" should do the job.

The code sample from my last comment can handle this I hope.

kika’s picture

Status: Needs review » Active

atom.module also needs a GUID so it is probably worth to introduce a genereric function

More background reading:

http://diveintomark.org/archives/2004/05/28/howto-atom-id
http://atompub.org/2005/07/11/draft-ietf-atompub-format-10.html#rfc.sect...

btw, 'created' timestamp also adds extra uniqueness

Gábor Hojtsy’s picture

Status: Active » Fixed

Drupal 4.7 and up has this feature. Look at http://drupal.org/rss.xml to see. It has <guid isPermaLink="false">77562 at http://drupal.org</guid> type guids.

Anonymous’s picture

Status: Fixed » Closed (fixed)