diff --git a/core/includes/common.inc b/core/includes/common.inc index eedd47a0cb81fc6a56acb36da1a5a83c7cd08cfe..85f1da761f03510077066575fa142adcf0d40322 100644 --- a/core/includes/common.inc +++ b/core/includes/common.inc @@ -233,39 +233,6 @@ function drupal_get_html_head($render = TRUE) { } } -/** - * Adds a feed URL for the current page. - * - * This function can be called as long the HTML header hasn't been sent. - * - * @param $url - * An internal system path or a fully qualified external URL of the feed. - * @param $title - * The title of the feed. - * - * @deprecated in Drupal 8.0.x, will be removed before Drupal 8.0.0 - * Use #attached on render arrays. - */ -function _drupal_add_feed($url = NULL, $title = '') { - $stored_feed_links = &drupal_static(__FUNCTION__, array()); - - if (isset($url)) { - $stored_feed_links[$url] = array('url' => $url, 'title' => $title); - } - return $stored_feed_links; -} - -/** - * Gets the feed URLs for the current page. - * - * @deprecated in Drupal 8.0.x, will be removed before Drupal 8.0.0 - * Use #attached on render arrays. - */ -function drupal_get_feeds() { - $feeds = _drupal_add_feed(); - return $feeds; -} - /** * Prepares a 'destination' URL query parameter for use with url(). * @@ -1870,7 +1837,13 @@ function drupal_process_attached($elements, $dependency_check = FALSE) { call_user_func_array('_drupal_add_html_head', $args); break; case 'feed': - call_user_func_array('_drupal_add_feed', $args); + $args = [[ + 'href' => $args[0], + 'rel' => 'alternate', + 'title' => $args[1], + 'type' => 'application/rss+xml', + ]]; + call_user_func_array('_drupal_add_html_head_link', $args); break; case 'html_head_link': call_user_func_array('_drupal_add_html_head_link', $args); diff --git a/core/includes/theme.inc b/core/includes/theme.inc index 303db67ee1ed51cd367478e8b97abe2c15bf06ba..b3208324328a11348be42ba7addc9f6371a26c27 100644 --- a/core/includes/theme.inc +++ b/core/includes/theme.inc @@ -17,7 +17,6 @@ use Drupal\Core\Config\StorageException; use Drupal\Core\Extension\Extension; use Drupal\Core\Extension\ExtensionNameLengthException; -use Drupal\Core\Page\FeedLinkElement; use Drupal\Core\Page\LinkElement; use Drupal\Core\Page\MetaElement; use Drupal\Core\Template\Attribute; @@ -1776,24 +1775,10 @@ function template_preprocess_page(&$variables) { if (!defined('MAINTENANCE_MODE')) { $variables['action_links'] = menu_get_local_actions(); $variables['tabs'] = menu_local_tabs(); - - // Convert drupal_get_feeds to feed links on the page object. - /** @var \Drupal\Core\Page\HtmlPage $page */ - $page = $variables['page']['#page']; - // Render the feed icons. - $variables['feed_icons'] = array(); - foreach ($page->getFeedLinkElements() as $link) { - $variables['feed_icons'][] = array( - '#theme' => 'feed_icon', - '#url' => $link->getAttributes()['href'], - '#title' => $link->getAttributes()['title'], - ); - } } else { $variables['action_links'] = array(); $variables['tabs'] = array(); - $variables['feed_icons'] = ''; } if ($node = \Drupal::routeMatch()->getParameter('node')) { diff --git a/core/lib/Drupal/Core/Page/DefaultHtmlFragmentRenderer.php b/core/lib/Drupal/Core/Page/DefaultHtmlFragmentRenderer.php index 8a229864a5b2056211fa5101af4f6f0b7030513a..00ec37a4a148e5148acac109a83620db8a231637 100644 --- a/core/lib/Drupal/Core/Page/DefaultHtmlFragmentRenderer.php +++ b/core/lib/Drupal/Core/Page/DefaultHtmlFragmentRenderer.php @@ -109,15 +109,6 @@ public function preparePage(HtmlPage $page, &$page_array) { $this->setDefaultMetaTags($page); - // @todo: collect feed links from #attached rather than a static once - // http://drupal.org/node/2256365 is completed. - foreach (drupal_get_feeds() as $feed) { - // Force the URL to be absolute, for consistency with other tags - // output by Drupal. - $link = new FeedLinkElement($feed['title'], _url($feed['url'], array('absolute' => TRUE))); - $page->addLinkElement($link); - } - // Add libraries and CSS used by this theme. $active_theme = \Drupal::theme()->getActiveTheme(); foreach ($active_theme->getLibraries() as $library) { diff --git a/core/modules/system/src/Tests/Common/AddFeedTest.php b/core/modules/system/src/Tests/Common/AddFeedTest.php index 3b495b3695b837266c20bbb1040f6679efc22d1e..ba55937e128ada08512e65085c6f101f4cd68de7 100644 --- a/core/modules/system/src/Tests/Common/AddFeedTest.php +++ b/core/modules/system/src/Tests/Common/AddFeedTest.php @@ -12,13 +12,14 @@ use Drupal\simpletest\WebTestBase; /** - * Make sure that _drupal_add_feed() works correctly with various constructs. + * Make sure that attaching feeds works correctly with various constructs. * * @group Common */ class AddFeedTest extends WebTestBase { + /** - * Tests _drupal_add_feed() with paths, URLs, and titles. + * Tests attaching feeds with paths, URLs, and titles. */ function testBasicFeedAddNoTitle() { $path = $this->randomMachineName(12); diff --git a/core/modules/system/templates/page.html.twig b/core/modules/system/templates/page.html.twig index 41d8270395a574d64569e4838992b09204456f33..88fc563cc017526bd89591c916bd3d825d1cc70f 100644 --- a/core/modules/system/templates/page.html.twig +++ b/core/modules/system/templates/page.html.twig @@ -39,7 +39,6 @@ * view and edit tabs when displaying a node). * - action_links: Actions local to the page, such as "Add menu" on the menu * administration interface. - * - feed_icons: All feed icons for the current page. * - node: Fully loaded node, if there is an automatically-loaded node * associated with the page and the node ID is the second argument in the * page's path (e.g. node/12345 and node/12345/revisions, but not @@ -122,8 +121,6 @@ {% endif %} {{ page.content }} - - {{ feed_icons }} {# /.layout-content #} {% if page.sidebar_first %} diff --git a/core/modules/views/src/Plugin/views/style/Rss.php b/core/modules/views/src/Plugin/views/style/Rss.php index 88c6e46f05da251724d43692c64c928659f5c0aa..d40acf2f830ebb00dd0e4925ec565613637b42f0 100644 --- a/core/modules/views/src/Plugin/views/style/Rss.php +++ b/core/modules/views/src/Plugin/views/style/Rss.php @@ -33,7 +33,6 @@ class Rss extends StylePluginBase { protected $usesRowPlugin = TRUE; public function attachTo(array &$build, $display_id, $path, $title) { - $display = $this->view->displayHandlers->get($display_id); $url_options = array(); $input = $this->view->getExposedInput(); if ($input) { @@ -42,29 +41,21 @@ public function attachTo(array &$build, $display_id, $path, $title) { $url_options['absolute'] = TRUE; $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']['feed'][] = array($url, $title); - } - } - else { - // Add the RSS icon to the view. - $feed_icon = array( - '#theme' => 'feed_icon', - '#url' => $url, - '#title' => $title, - ); - $this->view->feed_icon = $feed_icon; - - // Attach a link to the RSS feed, which is an alternate representation. - $build['#attached']['html_head_link'][][] = array( - 'rel' => 'alternate', - 'type' => 'application/rss+xml', - 'title' => $title, - 'href' => $url, - ); - } + + // Add the RSS icon to the view. + $this->view->feed_icon = [ + '#theme' => 'feed_icon', + '#url' => $url, + '#title' => $title, + ]; + + // Attach a link to the RSS feed, which is an alternate representation. + $build['#attached']['html_head_link'][][] = array( + 'rel' => 'alternate', + 'type' => 'application/rss+xml', + 'title' => $title, + 'href' => $url, + ); } protected function defineOptions() { diff --git a/core/modules/views/src/Tests/Wizard/BasicTest.php b/core/modules/views/src/Tests/Wizard/BasicTest.php index 9b6e0f2fbc6c8348418b07a2061884699b881e66..b404dd4e827d028f840285171597ed575375a1a5 100644 --- a/core/modules/views/src/Tests/Wizard/BasicTest.php +++ b/core/modules/views/src/Tests/Wizard/BasicTest.php @@ -74,7 +74,8 @@ function testViewsWizardAndListing() { $this->assertText($node2->label()); // Check if we have the feed. - $this->assertLinkByHref(_url($view2['page[feed_properties][path]'])); + $elements = $this->cssSelect('link[href="' . _url($view2['page[feed_properties][path]'], ['absolute' => TRUE]) . '"]'); + $this->assertEqual(count($elements), 1, 'Feed found.'); $this->drupalGet($view2['page[feed_properties][path]']); $this->assertRaw(' {% endif %} {{ page.content }} - {{ feed_icons }} {% if page.sidebar_first %} diff --git a/core/themes/seven/templates/page.html.twig b/core/themes/seven/templates/page.html.twig index e2cf74f4a50028fdb2023aa5f8a8364fccc27b1c..b2cc0bfb9dd5c6bb3548f5172aedbdafc146055c 100644 --- a/core/themes/seven/templates/page.html.twig +++ b/core/themes/seven/templates/page.html.twig @@ -40,7 +40,6 @@ * view and edit tabs when displaying a node). * - action_links: Actions local to the page, such as "Add menu" on the menu * administration interface. - * - feed_icons: All feed icons for the current page. * - node: Fully loaded node, if there is an automatically-loaded node * associated with the page and the node ID is the second argument in the * page's path (e.g. node/12345 and node/12345/revisions, but not @@ -95,10 +94,5 @@ {% endif %} {{ page.content }} - {% if feed_icons %} - - {% endif %}