Problem/Motivation

The feed URL is hard coded to 'rss.xml' and the link only works when clicked on home page.
The URL is provided by frontpage view
core/modules/node/config/optional/views.view.frontpage.yml:264: path: rss.xml

Steps to reproduce

- visit user profile page /user
- click on RSS feed icon in syndicate block or "Subscribe to" link
- expected to get xml listing

Proposed resolution

Add test that makes sure that /rss.xml link could be visited when user on /user page

Remaining tasks

review/commit

User interface changes

no

API changes

no

Data model changes

no

Release notes snippet

no

Comments

Chi created an issue. See original summary.

chi’s picture

Title: SyndicateBlock outputs wrong URL » Syndicate block outputs wrong feed URL
Issue summary: View changes

Also SyndicateBlock::defaultConfiguration() method seems unused.

andypost’s picture

Issue tags: +php-novice
andypost’s picture

Issue tags: +Needs tests
anantjain60’s picture

Status: Active » Needs review
StatusFileSize
new755 bytes
johnwebdev’s picture

I was just to upload a test for this, but I missed the Novice tag, so this is a great exercise for someone who wants to learn about writing tests for Drupal!

For those interesting in how we can add a test for this, there is an existing test at core/modules/node/tests/src/Functional/NodeSyndicateBlockTest.php.

Within that test we have a

testSyndicateBlock

method.

which already adds the block and asserts that it exists, so the things left do is:

  1. Click on the link in the block, that would be "Subscribe to"
  2. And then assert that the URL is correct

At this point we would have a failing test without the patch from #5 applied. Apply that patch and run the test again. It should pass. Now upload only the test as a patch, and then the test with the patch from #5 so we prove that the test fixes the issue in the first place.

Ping @johndevman on Slack, if you need some assistance :)

johnwebdev’s picture

Status: Needs review » Needs work

Needs work for test by the way!

jmikii’s picture

Version: 8.8.x-dev » 8.7.x-dev
Status: Needs work » Needs review
Issue tags: -Needs tests +DevDaysCluj
StatusFileSize
new1.07 KB

Added the test for checking Subscribe to link and that the url is correct.

Status: Needs review » Needs work

The last submitted patch, 8: Syndicate-block-feed-URL-3048848-8-test-only.patch, failed testing. View results

jmikii’s picture

StatusFileSize
new1.81 KB

Patch #5 with test #8

andypost’s picture

Version: 8.7.x-dev » 8.8.x-dev
Status: Needs work » Needs review

Patches goes to 8.8 first

Status: Needs review » Needs work

The last submitted patch, 10: Syndicate-block-feed-URL-3048848-10.patch, failed testing. View results

jmikii’s picture

Version: 8.8.x-dev » 8.7.x-dev
StatusFileSize
new1.07 KB
new1.8 KB

I have modified the Url to base:uri instead of internal:uri to include /subdirectory/ in case it exists in the url configuration.

jmikii’s picture

Version: 8.7.x-dev » 8.8.x-dev
Status: Needs work » Needs review

Version update

jmikii’s picture

Found that the /subdirectory/ problem is solved when assertUrl receives Url object.

andypost’s picture

Status: Needs review » Reviewed & tested by the community
alexpott’s picture

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

This block is really odd. I think we need a follow-up to address the fact that the rss.xml comes from a view so this block only works when views and node is installed and the views.view.frontpage exists. I think the block should be provided by the view and we should deprecate SyndicateBlock. Or we need to do the work to provide an fallback for rss.xml in the Node module.

That said this fix is a valid fix for the problem at hand.

  1. +++ b/core/modules/node/tests/src/Functional/NodeSyndicateBlockTest.php
    @@ -34,4 +36,20 @@ public function testSyndicateBlock() {
    +  /**
    +   * 1. Click on the "Subscribe to" link
    +   * 2. Assert that the Subscribe to url is correct
    +   */
    

    This should be something like Tests the syndicate block RSS link.

  2. +++ b/core/modules/node/tests/src/Functional/NodeSyndicateBlockTest.php
    @@ -34,4 +36,20 @@ public function testSyndicateBlock() {
    +    $this->drupalGet('');
    

    I think rather then requesting '' we should be explicit about requesting a page like user. Yes it is the same result BUT this bug is about the syndicate block not working on pages other than the frontpage.

  3. +++ b/core/modules/node/tests/src/Functional/NodeSyndicateBlockTest.php
    @@ -34,4 +36,20 @@ public function testSyndicateBlock() {
    +    $link = Url::fromUri('internal:/rss.xml');
    +    $this->assertUrl($link);
    

    I think this can be $this->assertSession()->addressEquals('rss.xml'); - I don't think we need to generate a Url object for this and we can use the non legacy methods.

chi’s picture

Given that the block was broken for many years I think no one uses it.

chi’s picture

+++ b/core/modules/node/tests/src/Functional/NodeSyndicateBlockTest.php
@@ -34,4 +36,20 @@ public function testSyndicateBlock() {
+    $this->clickLink(t('Subscribe to'));

Just out of curiosity, is it proper to use t() function in tests?

alexpott’s picture

@Chi nope we shouldn't be using t() in tests - nice spot.

rosinegrean’s picture

Issue tags: -DevDaysCluj +DevDaysTransylvania
carletex’s picture

Attaching a new patch (and an interdiff) with the changes that @alexpott suggested, plus fixing some CS.

I also agree that it makes more sense for this block to by provided by views.view.frontpage.

carletex’s picture

Sorry, wrong paths in the patches. Trying again.

andypost’s picture

+++ b/core/modules/node/tests/src/Functional/NodeSyndicateBlockTest.php
@@ -34,4 +37,18 @@ public function testSyndicateBlock() {
+    $this->assertSession()->addressEquals('rss.xml');

not sure it will work for CI tests - they running in subdir for that purpose - "checkout/" iirc

carletex’s picture

Is there a way to check if it works on CI tests?

andypost’s picture

Status: Needs work » Needs review

But it works)

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.0-alpha1 will be released the week of October 14th, 2019, which means new developments and disruptive changes should now be targeted against the 8.9.x-dev branch. (Any changes to 8.9.x will also be committed to 9.0.x in preparation for Drupal 9’s release, but some changes like significant feature additions will be deferred to 9.1.x.). For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.9.x-dev » 9.1.x-dev

Drupal 8.9.0-beta1 was released on March 20, 2020. 8.9.x is the final, long-term support (LTS) minor release of Drupal 8, which means new developments and disruptive changes should now be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

chi’s picture

Issue tags: - +Needs reroll
chi’s picture

Status: Needs review » Needs work
+  /**
+   * Tests the syndicate block RSS link.
+   */
+  public function testSyndicateBlockUrl() {
+    // Place the "Syndicate" block.
+    $this->drupalPlaceBlock('node_syndicate_block', ['id' => 'test_syndicate_block']);
+    $this->drupalGet('user');
+
+    $this->clickLink('Subscribe to');
+
+    $this->assertSession()->addressEquals('rss.xml');
+
+  }

The comment 'Place "the Syndicate" block.' seems redundant as the following code is quite readable. Also I would take out a new line at the end of the function.

mrinalini9’s picture

Status: Needs work » Needs review
StatusFileSize
new1.65 KB

Rerolled patch #24 for 9.1.x and also addressed comment from #31, please review.

himanshu_sindhwani’s picture

StatusFileSize
new1.65 KB

Point 2 from #31 was not addressed therefore fixed the same from #32

rachel_norfolk’s picture

Just come across this due to adding the block as per the new Olivero theme beta, which uses the block.

Probably worth noting that "Given that the block was broken for many years I think no one uses it." in #19 won't be true for long!

rachel_norfolk’s picture

Status: Needs review » Reviewed & tested by the community

Okay, I'm testing the patch by actually running it on https://rachelnorfolk.me and it works really well - no matter the current path, now the main site RSS feed in the syndication block remains correct. It works!

The test seem reasonable and they pass.

I see no code issues reported in the code related to this change.

I say RTBC.

quietone’s picture

Status: Reviewed & tested by the community » Needs review
Issue tags: -Needs reroll +Bug Smash Initiative, +Needs issue summary update

Reviewing RTBC issues as part of Bug Smash Initiative.

This looks good, just a few things to tidy up.

I read the issue summary and it explains the problem but there is no solution listed. Adding tag for IS update.

On reading the issue there is a request for a followup in #18 that sill needs to be done. The other changes to the patch have all been made. I didn't spot any other unfinished work. Yay!

There is a 'needs reroll' tag on the issue but that seems to have been done. Please remember to update tags as work is completed.

Next I looked at the patch and found a line > 80 chars.

+++ b/core/modules/node/tests/src/Functional/NodeSyndicateBlockTest.php
@@ -39,4 +39,17 @@ public function testSyndicateBlock() {
+    // Place the "Syndicate" block and confirm that the user is redirected to the subsciption page.

Line > 80 characters.

andypost’s picture

Fix #36 and optimize test suite, updated IS, filed follow-up #3174990: Test that SyndicateBlock works when views disabled

+++ b/core/modules/node/tests/src/Functional/NodeSyndicateBlockTest.php
@@ -39,4 +39,17 @@ public function testSyndicateBlock() {
     $this->assertFieldByXPath('//div[@id="block-test-syndicate-block"]/*', NULL, 'Syndicate block found.');
...
+    $this->clickLink('Subscribe to');
...
+    $this->assertSession()->addressEquals('rss.xml');

Any reason for separate assertion? it just one more install and slowdown of whole suite

The last submitted patch, 37: 3048848-37-fail.patch, failed testing. View results

Version: 9.1.x-dev » 9.2.x-dev

Drupal 9.1.0-alpha1 will be released the week of October 19, 2020, which means new developments and disruptive changes should now be targeted for the 9.2.x-dev branch. For more information see the Drupal 9 minor version schedule and the Allowed changes during the Drupal 9 release cycle.

sulfikar_s’s picture

Hello, the previous patch failed to apply to 9.2.x-dev. See below,

patch-apply-error

I've re-rolled the patch in #37

Please review.

Version: 9.2.x-dev » 9.3.x-dev

Drupal 9.2.0-alpha1 will be released the week of May 3, 2021, which means new developments and disruptive changes should now be targeted for the 9.3.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

guilhermevp’s picture

Status: Needs review » Reviewed & tested by the community
StatusFileSize
new60.22 KB
new60.22 KB

Patch still applies in 9.3.x, and works as intended.

Before patch I was able to reproduce the error:

1

After patch, the error is gone. Tests are more efficient now and test-only patch fails. So, I'm moving to RTBC.

larowlan’s picture

Updating issue credits

  • larowlan committed a8d54a5 on 9.2.x
    Issue #3048848 by jmikii, carletex, andypost, sulfikar_s, mrinalini9,...
  • larowlan committed acb621d on 9.3.x
    Issue #3048848 by jmikii, carletex, andypost, sulfikar_s, mrinalini9,...
larowlan’s picture

Version: 9.3.x-dev » 9.2.x-dev
Status: Reviewed & tested by the community » Fixed

Committed acb621d and pushed to 9.3.x. Thanks!

Status: Fixed » Closed (fixed)

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