We have two good reasons to remove {{ feed_icons }}:

One: because it stands in the way of better page rendering

As part of #2350943: [Meta] Untangle Drupal 8 page rendering, we concluded that we want to try to complete the conversion away from "random variables" for the page template (page.html.twig) towards using only regions.

One of the things encountered in the page template is the feed_icons variable. This used to rely on drupal_render() storing encountered attached feeds in a global static variable. And in fact it still does. But we're moving away from that — that's been a long-term goal of WSCCI/SCOTCH, and we're mostly there. This is one of the last blockers.

The reason it currently works is that the *contents* of the page are first rendered into a HtmlPage object, which also calls drupal_process_attached() and hence calls _drupal_add_feed(). This, in turn, ensures that a call to drupal_get_feeds() works as expected. Hence template_preprocess_page() can call drupal_get_feeds() and get meaningful results. But, we're removing HtmlPage and as part of that, the parts within the page are only going to be rendered after template_preprocess_page() has run, and hence the #attached feeds for the child render arrays won't have been processed yet.

The solution is super simple: make ['#attached']['feed'] simply an alias of ['#attached']['html_head_link'], which automatically sets the rel=alternate and type=application/rss+xml attributes.

Two: because it's antiquated, inflexible, imposing, ugly and mostly useless

Finally, I'm fairly certain that it's a pointless feature anyway in 2014 and beyond:

  1. I'm willing to bet themers hate this special snowflake {{ feed_icons }} in their Twig templates
  2. It looks ugly and off.
  3. If you really want icons for your feeds, you're probably going to use the "Syndicate" block, or custom blocks, so that you can control where the feed icons appear, rather than them being hardcoded.
  4. Very, very, very few people ever use it, since browsers make it easy to know there's a feed to subscribe to on the current page, since there's of course still the <link> tag.

Comments

wim leers’s picture

Status: Active » Needs review
StatusFileSize
new8.76 KB

Note that we keep theme_feed_icon and feed-icon.html.twig around, because e.g. the "Syndicate" block uses it, as does the aggregator module, as does Views.

wim leers’s picture

Note that we keep theme_feed_icon and feed-icon.html.twig around, because e.g. the "Syndicate" block uses it, as does the aggregator module, as does Views.

catch’s picture

Also if someone really wanted the automatic feature, it could be done using js - that way you have access to the final<head> output.

Status: Needs review » Needs work

The last submitted patch, 1: remove_page_feed_icons-2357937-1.patch, failed testing.

wim leers’s picture

Status: Needs work » Needs review
StatusFileSize
new9.63 KB
new935 bytes

A single test fail, due to a single test wrongly relying on the feed icon being present rather than a <link href="FEED URL" /> tag being present.

dawehner’s picture

Very, very, very few people ever use it, since browsers make it easy to know there's a feed to subscribe to on the current page, since there's of course still the
tag.

I am sorry but this statement is 100% wrong. Have a look at the following URL with your browser: https://www.drupal.org/node
Neither chrome nor firefox helps you to figure out that there is a feed. Yes, it used to be like that, but this is no longer the case. Showing people that you have an RSS feed available is a thing for blogs.

dawehner’s picture

And note: views has probably just no test coverage but renders out the icon by default on /node

catch’s picture

@dawehner this wouldn't get rid of the Views rendering (or at least it shouldn't).

wim leers’s picture

That's a fair point, but nowadays people use bookmarklets, browser extensions or write/copy'npaste the website URL (e.g. http://wimleers.com) and then the feed reader figures out which feeds are available. So it's really not a big problem. I don't know a single prominent site anymore that shows feed icons, but almost all of them provide a feed in a <link> tag.

All other points still stand, and further reduce the problematicness of your (valid!) point: the "Syndicate" block still exists, and Views has the ability to show a feed icon as well.

The point is that this doesn't belong in the page template, where you don't have good control over it.

lauriii’s picture

Issue tags: +Needs bikeshedding
rteijeiro’s picture

StatusFileSize
new20.7 KB

I agree that there is no need of having a RSS attached to every single Drupal page. It's a better solution to provide it if you really need it using the Syndicate block.

Patch looks pretty and also provided screenshots:

BEFORE

Only local images are allowed.

AFTER

dawehner’s picture

All other points still stand, and further reduce the problematicness of your (valid!) point: the "Syndicate" block still exists, and Views has the ability to show a feed icon as well.

Looking at #2357937-11: Remove {{ feed_icons }} from page template (page.html.twig) views seem to have lost the capability to render it, didn't it :)

lars toomre’s picture

Does it make sense then to add the js code to add access to the final head output? That would satisfy both @wim and @dawehner's concerns.

wim leers’s picture

#12: No, that's the removed {{ feed_icons }} in page.html.twig that you're seeing (well, not seeing anymore, of course). There still is {{ feed_icon }} in views-view.html.twig! :)

#13: No, that'd be even worse, since that'd mean we'd be loading JS for something that is used only extremely rarely, and it'd mean loading JS for anonymous users again. I appreciate the suggestion though! :)

Jeff Burnz’s picture

Yep, good call, lets get rid of it. +1 for the reasons stated in the OP.

lewisnyman’s picture

+1, if people do use RSS then they don't use it like this.

catch’s picture

Does this mean the front page view needs configuring the show the RSS icon though?

lewisnyman’s picture

StatusFileSize
new721.8 KB

I am sorry but this statement is 100% wrong. Have a look at the following URL with your browser: https://www.drupal.org/node
Neither chrome nor firefox helps you to figure out that there is a feed. Yes, it used to be like that, but this is no longer the case. Showing people that you have an RSS feed available is a thing for blogs.

They don't because they removed support for it. If you care enough then you can download an RSS plugin. Here it is in action:

wim leers’s picture

Does this mean the front page view needs configuring the show the RSS icon though?

IMHO it doesn't. It's antiquated to show it at all, as I mentioned in #9 — do you know of any prominent sites still showing the RSS feed icon? As LewisNyman showed in #18, people using feeds can easily make

dawehner’s picture

IMHO it doesn't. It's antiquated to show it at all, as I mentioned in #9 — do you know of any prominent sites still showing the RSS feed icon? As LewisNyman showed in #18, people using feeds can easily make

Well yeah I think power users would use some browser plugin anyway.

For blogs using the syndicate block is probably a good idea.

@Wim Leers
We need to update the Rss.php

wim leers’s picture

We need to update the Rss.php

Why? Nothing in this patch affects that code? So are you saying we should make it more consistent? Or fix a bug? Or…?

dawehner’s picture

Why? Nothing in this patch affects that code? So are you saying we should make it more consistent? Or fix a bug? Or…?

Just to be sure, I try to be nice again ;)

The current code looks like the following:

    $url = _url($this->view->getUrl(NULL, $path), $url_options);
    if ($display->hasPath()) {
      if (empty($this->preview)) {
        // Add a call for drupal_add_feed to the view attached data.
        $build['#attached']['drupal_add_feed'][] = array($url, $title);
      }
    }
    else {
      $feed_icon = array(
        '#theme' => 'feed_icon',
        '#url' => $url,
        '#title' => $title,
      );
      $this->view->feed_icon = $feed_icon;

      // Add a call for drupal_add_html_head_link to the view attached data.
      $build['#attached']['drupal_add_html_head_link'][][] = array(
        'rel' => 'alternate',
        'type' => 'application/rss+xml',
        'title' => $title,
        'href' => $url,
      );
    }
  }

So for page displays we use drupal_add_feed() which allows us to get rid of adding doing a lot of stuff. For blocks we can't that easy render the feed icon, so
we have to drop more code, as well as get rid of $view->feed_icon, I guess ...

Just to be clear, we would have to expand the capabilities of the syndicate block to make it actually useful.

joelpittet’s picture

Just from "prominent sites" argument using the icon, when I'm testing the RSS aggregator I always go to news sites:
BBC

NBC

CBC

I do agree with removing it so big +1 to this issue in general. And RSS is getting used much less than it was(Damn you twitter!)

Just want to echo @dawehner's concerns and hope we don't rush to hastily to remove a feature without providing a DX friendly alternative.

What's the plan to make it fairly easy to add tags/elements to head from blocks, views, wherever? #attached is covering js/css well enough at the moment. Specifically it looks like _drupal_add_html_head_link is a deprecated function, so were is that headed?

Feed icon should be fine removed as long as we can get the feed_url to the template a themer can wrap it around their SVG, png, icon font, or whatever. Which should be really easy on a Views template id' expect. Getting rid of view->feed_icon should be fine to do as long as feed_url is discoverable.

joelpittet’s picture

To answer my own question, as I wasn't aware...
Change record (updated because there was a typo for feed):
https://www.drupal.org/node/2160069

Couple of questions on the current patch:

  1. +++ b/core/includes/common.inc
    @@ -234,39 +234,6 @@ function drupal_get_html_head($render = TRUE) {
    -function _drupal_add_feed($url = NULL, $title = '') {
    -  $stored_feed_links = &drupal_static(__FUNCTION__, array());
    

    Why a static here and is it still needed in drupal_process_attached now that the code has moved there?

  2. +++ b/core/includes/common.inc
    @@ -1872,7 +1839,13 @@ function drupal_process_attached($elements, $dependency_check = FALSE) {
    +          $args = [[
    +            'href' => $args[0],
    +            'rel' => 'alternate',
    +            'title' => $args[1],
    +            'type' => 'application/rss+xml',
    +          ]];
    +          call_user_func_array('_drupal_add_html_head_link', $args);
    

    Doesn't this make it difficult to change the type if it's an opml feed or something?

rainbowarray’s picture

Removing this special snowflake variable has been in my head for months now. Thanks for taking care of this Wim.

I used to use RSS all the time. I can't remember the last time I used it. As I grow more disenchanted with Twitter, I think about returning to RSS. But core should be solving the 80% use cases, and I'm not sure having a RSS link visible on the page falls into that 80% use case anymore.

+1 to saying goodbye to the feeds variable.

andypost’s picture

+1 to remove in favour of block

IMO most of sites needs separate block with own links so RSS is mostly an icon within others in "social" block and I would like to see follow-up to transform "syndicate" block into a kind of "follow" block.

@dawehner +1 to

For blocks we can't that easy render the feed icon, so
we have to drop more code, as well as get rid of $view->feed_icon, I guess ...

Only page views should be able to expose head link.

dawehner’s picture

@Wim Leers
Sure, we can remove it, but we should be aware of the fact that the syndicate block is that helpful for the day to day use.
It simply points to '/rss.xml' which is one URL controlled by views. People might easily build other rss feeds, so we maybe should expand that block a bit.

andypost’s picture

#27 suppose it's not good idea to allow a block to get page state...

wim leers’s picture

RE: BBC/CBC/NBC: fair :) So that aspect was then biased by the sites *I* visit on the internet, which don't have it anymore. Though these indeed show that there is usually only a single feed link, and it's usually styled in a customized way. Perfect fit for the "Syndicate" block, or quite possibly for a custom "Follow us" block, with RSS + social media links, which seems to be the new pattern.

What's the plan to make it fairly easy to add tags/elements to head from blocks, views, wherever? #attached is covering js/css well enough at the moment. Specifically it looks like _drupal_add_html_head_link is a deprecated function, so were is that headed?

This is already covered: ['#attached']['html_head_link'] for <link> tags in <head>, ['#attached']['html_head'] for *any* tag in <head>. Works for blocks, views, wherever… even preprocess functions :)

Getting rid of view->feed_icon should be fine to do as long as feed_url is discoverable

I'll repeat what I said in #14:

#12: No, that's the removed {{ feed_icons }} in page.html.twig that you're seeing (well, not seeing anymore, of course). There still is {{ feed_icon }} in views-view.html.twig! :)

i.e. this is not changing Views in any way.


#24.1: I don't understand the question.

#24.2: It's always been like this. This is not an API change.


#25: I still use RSS :) But most of the time, no icons are available, in my experience. It doesn't really matter, because either the browser or a bookmarklet will discover the RSS feed for me.


#26: Agreed that having a "Follow" block would be a nice-to-have. The thing is: social services keep evolving, and come and go. So creating a block that includes a certain set of social media services will quickly be outdated. The included/associated icons will be even more quickly outdated. Therefore, this is not something core can and should do. Hence just sticking with the "Syndicate" block for now seems to be the best course of action.


#27/#28: It's true that the "Syndicate" block hardcodes a certain URL. But it's a 90% use case. Most sites who have more feeds will also want to link to social media, and then my answer to #26 is relevant again. Hence I'd once again that just sticking with the "Syndicate" block for now seems to be the best course of action.

wim leers’s picture

StatusFileSize
new10.94 KB
new2.07 KB

Discusssed with dawehner, this is what he wanted to see still happen in Views.

andypost’s picture

I think core's standard profile could ship placed syndicate block into main content region to emulate BC for taxonomy pages at least. And only one nitpick:

+++ b/core/modules/views/src/Plugin/views/style/Rss.php
@@ -42,29 +41,22 @@ public function attachTo(array &$build, $display_id, $path, $title) {
+    $feed_icon = array(
+      '#theme' => 'feed_icon',
...
+    $this->view->feed_icon = $feed_icon;

$feed_icon is useless variable now

wim leers’s picture

StatusFileSize
new10.9 KB
new896 bytes

Fixed #31 nitpick.


I think core's standard profile could ship placed syndicate block into main content region to emulate BC for taxonomy pages at least.

I don't think this is necessary. If others think this should happen, I'll reroll the patch to do this. It'd be configured to only be visible on taxonomy/term/* pages.

wim leers’s picture

Correction for my previous comment: we should not place the Syndicate block for taxonomy term pages, because that would link to /rss.xml, not to the taxonomy term feeds. The interdiff in #30 should in theory bring back the feed icon to all page views, just with the feed icon in the view's template rather than the page template. In practice, however, it doesn't work.

It already is broken in HEAD, so fixing that is out of scope here. #2359161: Feed icons missing in views blocks and pages fixes it.

rainbowarray’s picture

Status: Needs review » Reviewed & tested by the community
Issue tags: -Needs bikeshedding

Reviewed this, looks good to me. dawehner's concerns appear to have been addressed, so I think this is all set.

joelpittet’s picture

Regarding the syndicate/follow block, I'm sure contrib could take care of that or if we need them they could be in a followup. I'm good with the RTBC, this is a nice cruft remover:)

Re:

#24.1: I don't understand the question.

I was just curious what that static cache was speeding up and if that "speed" was needed somewhere else in the patch.
I'm guessing it is no longer needed as we aren't _drupal_add_feeds'ing just adding another link to the head.

and #24.2 I see what you're doing now, keeping the API in tact is all... if someone were to want to do opml or something they can just build a ['#attached']['html_head_link'][]

webchick’s picture

Not marking down from RTBC, but aren't the screenshots in #23 advocating for *keeping* the feed icons on the page (either through Views or through a More Betterer Syndicate block)? No offense, but I'm not sure a bunch of Drupal core developers are a very representative sample of website users as a whole. ;) The fact that BBC et al keep one or more feed icons around rather than use that precious real estate as ad space seems to imply it's widely used by the internet at large (though as a counter-point I wasn't able to find such an icon on CNN.com, which AFAIK is the largest news website).

Anyway, rather than get into that whole debate, moving the RSS feed rendering to Views seems to address both issues in the OP (it doesn't futz with page rendering, and you can get rid of it if you want). So why are we trying to do this first, versus postponing on #2359161: Feed icons missing in views blocks and pages?

wim leers’s picture

#35: that static cache wasn't there for performance reasons, it was there for "remembering the feeds added on this page". It's one of those pesky globals that we've been trying to remove.

#36: We're trying to do this in parallel with #2359161: Feed icons missing in views blocks and pages. This blocks #2352155: Remove HtmlFragment/HtmlPage, which is critical. Turns out Views has had the capability to show feed icons all along, but it's been broken for some time. #2359161 also feels like it's getting stuck rather than moving forward.
Finally: BBC et al have highly customized, highly integrated "Follow us" blocks. As I explained at the bottom of #29 (the part that replies to #26): Drupal core by definition cannot provide such an awesome "Follow us" block (for similar reasons as why we can't have Responsive Preview in Drupal core with a hardcoded set of devices). Not just a crappy listing at the bottom of the page of feed icons literally sitting next to each other (with no margins between them), without any indication what each icon is for (unless you hover… which you can't on a touch device). This patch removes a "feature" that is 10 years old, has a crappy UX, has a crappy DX, and has a crappy TX.
I do promise I'll keep #2359161: Feed icons missing in views blocks and pages moving forward.

catch’s picture

Priority: Major » Critical

Given this blocks #2352155: Remove HtmlFragment/HtmlPage, bumping to critical.

Leaving RTBC a bit longer in case there's more to discuss, but personally I agree fixing the Views regression from 7.x is a separate issue to sorting out the chicken and egg page variable.

alexpott’s picture

Status: Reviewed & tested by the community » Needs work
Issue tags: +Needs change record

This issue needs a change record because it

removes a "feature" that is 10 years old, has a crappy UX, has a crappy DX, and has a crappy TX.

I guess the change record should be linked to the views issue to and once that is fixed contain instructions on how to build a replacement.

wim leers’s picture

Status: Needs work » Reviewed & tested by the community
Issue tags: -Needs change record

You're right, this changes the page.html.twig template and hence needs a CR.

Done: https://www.drupal.org/node/2362865

  • catch committed 2acc93b on 8.0.x
    Issue #2357937 by Wim Leers: Remove {{ feed_icons }} from page template...
catch’s picture

Status: Reviewed & tested by the community » Fixed

Thanks for the change notice.

Committed/pushed to 8.0.x, thanks!

If we want to bump #2359161: Feed icons missing in views blocks and pages to critical we should, I think it's major so it depends how much the missing feature is considered a regression (and whether that regression is worth holding the release up for).

damiankloip’s picture

afaik, that issue will not fix the now missing icons for pages? So it's not about fixing an existing regression, but creating a new one as well.

So this is knowingly creating bugs to help solve other bugs? :)

wim leers’s picture

#43: This patch made Page view displays with attached feeds also set feed icons, not just Block view displays, so that you effectively still have the same behavior. Only, that doesn't work because #2359161: Feed icons missing in views blocks and pages. So, no, the "now missing icons for pages" will come back once #2359161: Feed icons missing in views blocks and pages is fixed :)

damiankloip’s picture

Ok, then I missed something here. Thanks!

andypost’s picture

published CR

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.