drupal_add_feed:

1. adds the feed URL into a static map variable
2. also immediately calls drupal_add_link (which then immediately calls drupal_set_html_head)

These two actions are redundant, and the design of the function (and themes) should be rearranged such that one of the two actions is removed.

If drupal_set_html_head is called immediately, it isn't useful to store the URL map. It's too late to remove the link from the page, and the implementation of the map doesn't even make much sense. Consider the case where drupal_add_feed is called twice with the same URL.

If the map is to be stored, we shouldn't call drupal_set_html_head. Instead, the map should be output and formatted in the theme. That gives us the chance to remove items in the theme if we choose, and has the added benefit that it won't be possible to output the same RSS feed more than once on the same page.

CommentFileSizeAuthor
#3 112374.patch485 bytesWesley Tanaka
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Wesley Tanaka’s picture

It seems that these two actions are for two separate purposes. The static map is used to produce the list of feed links in theme_page, and the header is generated with the call to drupal_add_link

It seems like it would be much cleaner to have both outputs generated from the same map.

Wesley Tanaka’s picture

Title: drupal_add_feed does two redundant things » drupal_add_feed allows feeds to be added multiple times in header but not in content

It seems like javascript is also still handled in this "append strings" fashion, and that doing something along the lines of #1 would possibly break compatibility with 5.0 themes.

Changing the scope of the issue

Wesley Tanaka’s picture

Status: Active » Needs review
FileSize
485 bytes
m3avrck’s picture

Status: Needs review » Reviewed & tested by the community

I originally worked on the drupal_add_feed() and am happy with this patch. Kind of an obvious thing that was left out :-)

m3avrck’s picture

Version: 5.0 » 6.x-dev
Gábor Hojtsy’s picture

Status: Reviewed & tested by the community » Fixed

Although the patch itself did not apply, it was easy to type it in, instead of asking you to reroll, so committed!

Anonymous’s picture

Status: Fixed » Closed (fixed)