Issue #3070620 by idebr, Lendude: RSS <channel><link> element must refer to the website URL instead of the request URL
parent
7cbb0ca739
commit
82c4122b31
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
namespace Drupal\Tests\views\Functional\Plugin;
|
namespace Drupal\Tests\views\Functional\Plugin;
|
||||||
|
|
||||||
|
use Drupal\Core\Url;
|
||||||
use Drupal\Tests\views\Functional\ViewTestBase;
|
use Drupal\Tests\views\Functional\ViewTestBase;
|
||||||
use Drupal\views\Views;
|
use Drupal\views\Views;
|
||||||
|
|
||||||
|
@ -56,10 +57,12 @@ class DisplayFeedTest extends ViewTestBase {
|
||||||
|
|
||||||
// Test the site name setting.
|
// Test the site name setting.
|
||||||
$site_name = $this->randomMachineName();
|
$site_name = $this->randomMachineName();
|
||||||
|
$frontpage_url = Url::fromRoute('<front>')->setAbsolute()->toString();
|
||||||
$this->config('system.site')->set('name', $site_name)->save();
|
$this->config('system.site')->set('name', $site_name)->save();
|
||||||
|
|
||||||
$this->drupalGet('test-feed-display.xml');
|
$this->drupalGet('test-feed-display.xml');
|
||||||
$this->assertEquals($site_name, $this->getSession()->getDriver()->getText('//title'));
|
$this->assertEquals($site_name, $this->getSession()->getDriver()->getText('//title'));
|
||||||
|
$this->assertEquals($frontpage_url, $this->getSession()->getDriver()->getText('//link'));
|
||||||
$this->assertEquals($node_title, $this->getSession()->getDriver()->getText('//item/title'));
|
$this->assertEquals($node_title, $this->getSession()->getDriver()->getText('//item/title'));
|
||||||
// Verify HTML is properly escaped in the description field.
|
// Verify HTML is properly escaped in the description field.
|
||||||
$this->assertRaw('<p>A paragraph</p>');
|
$this->assertRaw('<p>A paragraph</p>');
|
||||||
|
@ -90,8 +93,8 @@ class DisplayFeedTest extends ViewTestBase {
|
||||||
$this->assertEqual($icon_href, $page_url . '/feed', 'The feed icon was found.');
|
$this->assertEqual($icon_href, $page_url . '/feed', 'The feed icon was found.');
|
||||||
$link_href = $this->cssSelect('link[type = "application/rss+xml"][href *= "test-feed-icon"]')[0]->getAttribute('href');
|
$link_href = $this->cssSelect('link[type = "application/rss+xml"][href *= "test-feed-icon"]')[0]->getAttribute('href');
|
||||||
$this->assertEqual($link_href, $page_url . '/feed', 'The RSS link was found.');
|
$this->assertEqual($link_href, $page_url . '/feed', 'The RSS link was found.');
|
||||||
$feed_link = simplexml_load_string($this->drupalGet($icon_href))->channel->link;
|
$this->drupalGet($icon_href);
|
||||||
$this->assertEqual($feed_link, $page_url, 'The channel link was found.');
|
$this->assertEquals($frontpage_url, $this->getSession()->getDriver()->getText('//channel/link'));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -866,32 +866,7 @@ function template_preprocess_views_view_rss(&$variables) {
|
||||||
$title = $view->getTitle();
|
$title = $view->getTitle();
|
||||||
}
|
}
|
||||||
$variables['title'] = $title;
|
$variables['title'] = $title;
|
||||||
|
$variables['link'] = Url::fromRoute('<front>')->setAbsolute()->toString();
|
||||||
// Figure out which display which has a path we're using for this feed. If
|
|
||||||
// there isn't one, use the global $base_url
|
|
||||||
$link_display_id = $view->display_handler->getLinkDisplay();
|
|
||||||
/** @var \Drupal\views\Plugin\views\display\DisplayPluginBase $display */
|
|
||||||
if ($link_display_id && ($display = $view->displayHandlers->get($link_display_id)) && $display->isEnabled()) {
|
|
||||||
$url = $view->getUrl(NULL, $link_display_id);
|
|
||||||
}
|
|
||||||
|
|
||||||
/** @var \Drupal\Core\Url $url */
|
|
||||||
if (!empty($url)) {
|
|
||||||
$url_options = ['absolute' => TRUE];
|
|
||||||
if (!empty($view->exposed_raw_input)) {
|
|
||||||
$url_options['query'] = $view->exposed_raw_input;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Compare the link to the default home page; if it's the default home page,
|
|
||||||
// just use $base_url.
|
|
||||||
$url_string = $url->setOptions($url_options)->toString();
|
|
||||||
if ($url_string === Url::fromUserInput($config->get('page.front'))->toString()) {
|
|
||||||
$url_string = Url::fromRoute('<front>')->setAbsolute()->toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
$variables['link'] = $url_string;
|
|
||||||
}
|
|
||||||
|
|
||||||
$variables['langcode'] = \Drupal::languageManager()->getCurrentLanguage()->getId();
|
$variables['langcode'] = \Drupal::languageManager()->getCurrentLanguage()->getId();
|
||||||
$variables['namespaces'] = new Attribute($style->namespaces);
|
$variables['namespaces'] = new Attribute($style->namespaces);
|
||||||
$variables['items'] = $items;
|
$variables['items'] = $items;
|
||||||
|
|
Loading…
Reference in New Issue