From 75debc110d4b8bbc2f5afdd60ddfd2c03bbd1c48 Mon Sep 17 00:00:00 2001
From: catch <catch@35733.no-reply.drupal.org>
Date: Mon, 28 Oct 2013 11:53:11 +0000
Subject: [PATCH] Issue #2115063 by marcingy: Remove drupal_add_feed().

---
 .../Drupal/aggregator/Controller/AggregatorController.php  | 6 +++---
 .../forum/lib/Drupal/forum/Controller/ForumController.php  | 7 +++----
 .../system/lib/Drupal/system/Tests/Common/AddFeedTest.php  | 4 +++-
 core/modules/taxonomy/taxonomy.pages.inc                   | 2 +-
 .../views/lib/Drupal/views/Plugin/views/style/Rss.php      | 3 ++-
 5 files changed, 12 insertions(+), 10 deletions(-)

diff --git a/core/modules/aggregator/lib/Drupal/aggregator/Controller/AggregatorController.php b/core/modules/aggregator/lib/Drupal/aggregator/Controller/AggregatorController.php
index 7b57afbef24e..4d5dd9abefcb 100644
--- a/core/modules/aggregator/lib/Drupal/aggregator/Controller/AggregatorController.php
+++ b/core/modules/aggregator/lib/Drupal/aggregator/Controller/AggregatorController.php
@@ -294,10 +294,10 @@ public function categories() {
    *   The rendered list of items for the feed.
    */
   public function pageLast() {
-    drupal_add_feed('aggregator/rss', $this->config('system.site')->get('name') . ' ' . $this->t('aggregator'));
-
     $items = $this->entityManager()->getStorageController('aggregator_item')->loadAll();
-    return $this->buildPageList($items);
+    $build = $this->buildPageList($items);
+    $build['#attached']['drupal_add_feed'][] = array('aggregator/rss', $this->config('system.site')->get('name') . ' ' . $this->t('aggregator'));
+    return $build;
   }
 
   /**
diff --git a/core/modules/forum/lib/Drupal/forum/Controller/ForumController.php b/core/modules/forum/lib/Drupal/forum/Controller/ForumController.php
index 95b29231dc77..e801c9dcb965 100644
--- a/core/modules/forum/lib/Drupal/forum/Controller/ForumController.php
+++ b/core/modules/forum/lib/Drupal/forum/Controller/ForumController.php
@@ -117,10 +117,6 @@ public function forumPage(TermInterface $taxonomy_term) {
     // Get forum details.
     $taxonomy_term->forums = $this->forumManager->getChildren($this->config->get('vocabulary'), $taxonomy_term->id());
     $taxonomy_term->parents = $this->forumManager->getParents($taxonomy_term->id());
-    if (empty($taxonomy_term->forum_container->value)) {
-      // Add RSS feed for forums.
-      drupal_add_feed('taxonomy/term/' . $taxonomy_term->id() . '/feed', 'RSS - ' . $taxonomy_term->label());
-    }
 
     if (empty($taxonomy_term->forum_container->value)) {
       $topics = $this->forumManager->getTopics($taxonomy_term->id());
@@ -178,6 +174,9 @@ protected function build($forums, TermInterface $term, $topics = array(), $paren
       '#forums_per_page' => $this->config->get('topics.page_limit'),
     );
     $build['#attached']['library'][] = array('forum', 'forum.index');
+    if (empty($term->forum_container->value)) {
+      $build['#attached']['drupal_add_feed'][] = array('taxonomy/term/' . $term->id() . '/feed', 'RSS - ' . $term->label());
+    }
 
     return $build;
   }
diff --git a/core/modules/system/lib/Drupal/system/Tests/Common/AddFeedTest.php b/core/modules/system/lib/Drupal/system/Tests/Common/AddFeedTest.php
index 3fbb36518c75..b871710c1588 100644
--- a/core/modules/system/lib/Drupal/system/Tests/Common/AddFeedTest.php
+++ b/core/modules/system/lib/Drupal/system/Tests/Common/AddFeedTest.php
@@ -71,9 +71,11 @@ function testBasicFeedAddNoTitle() {
     );
 
     foreach ($urls as $description => $feed_info) {
-      drupal_add_feed($feed_info['input_url'], $feed_info['title']);
+      $build['#attached']['drupal_add_feed'][] = array($feed_info['input_url'], $feed_info['title']);
     }
 
+    drupal_render($build);
+
     $this->drupalSetContent(drupal_get_html_head());
     foreach ($urls as $description => $feed_info) {
       $this->assertPattern($this->urlToRSSLinkPattern($feed_info['output_url'], $feed_info['title']), format_string('Found correct feed header for %description', array('%description' => $description)));
diff --git a/core/modules/taxonomy/taxonomy.pages.inc b/core/modules/taxonomy/taxonomy.pages.inc
index 3cf82e288f2b..fb88184a5b80 100644
--- a/core/modules/taxonomy/taxonomy.pages.inc
+++ b/core/modules/taxonomy/taxonomy.pages.inc
@@ -19,7 +19,7 @@ function taxonomy_term_page(Term $term) {
   // Assign the term name as the page title.
   drupal_set_title($term->label());
 
-  drupal_add_feed('taxonomy/term/' . $term->id() . '/feed', 'RSS - ' . $term->label());
+  $build['#attached']['drupal_add_feed'][] = array('taxonomy/term/' . $term->id() . '/feed', 'RSS - ' . $term->label());
 
   foreach ($term->uriRelationships() as $rel) {
     $uri = $term->uri($rel);
diff --git a/core/modules/views/lib/Drupal/views/Plugin/views/style/Rss.php b/core/modules/views/lib/Drupal/views/Plugin/views/style/Rss.php
index 90a5390fa223..7b1e0b183b4a 100644
--- a/core/modules/views/lib/Drupal/views/Plugin/views/style/Rss.php
+++ b/core/modules/views/lib/Drupal/views/Plugin/views/style/Rss.php
@@ -44,7 +44,8 @@ public function attachTo($display_id, $path, $title) {
     $url = url($this->view->getUrl(NULL, $path), $url_options);
     if ($display->hasPath()) {
       if (empty($this->preview)) {
-        drupal_add_feed($url, $title);
+        $build['#attached']['drupal_add_feed'][] = array($url, $title);
+        drupal_render($build);
       }
     }
     else {
-- 
GitLab