Problem/Motivation

The node module provides a "syndicate" block, which contains a link to rss.xml.

The link text is an unfinished sentence: "Subscribe to".

The link is generated in SyndicateBlock.php using '#theme' => 'feed_icon'.

The corresponding feed-icon.html.twig template expects a top-level variable called title like so:

{{ 'Subscribe to @title'|t({'@title': title}) }}.

However no title variable has been passed in to the theme template by SyndicateBlock.php, so the link is an unfinished sentence. It's not clear what was originally intended for this to say. We could look back to how things worked in D7, but at this stage that might not be relevant any more.

Proposed resolution

Pass in a title in to the feed_icon template, so the link text makes sense.

I suggest we use the site name for this.

Remaining tasks

  • Update SyndicateBlock.php
  • Check tests

User interface changes

API changes

Data model changes

Release notes snippet

Comments

andrewmacpherson created an issue. See original summary.

andrewmacpherson’s picture

Title: Link text in Syndicate block is half a sentence » Title variable isn't set by Syndicate block - so the link text is an unfinished sentence
andrewmacpherson’s picture

I noticed this problem after reviewing #3153860: Theme and Configure the RSS Feed Views Block in Olivero.

darchuletajr’s picture

Can I take a stab at this issue?

andrewmacpherson’s picture

Of course, go ahead!

darchuletajr’s picture

StatusFileSize
new4.34 KB

Not sure if this is overkill but I used dependency injection to get the site name from the config factory service. I could have also just used the Drupal object like so \Drupal::config('system.site')->get('name').

andrewmacpherson’s picture

Status: Active » Needs work
Issue tags: +Needs tests

This approach looks OK to me. It will need test coverage too.

  1. I had a look through various other block plugins in Drupal core to see if there was a preference for injecting the config factory service, or using the Drupal object. I found examples of both! The UserLoginBlock uses \Drupal::config(), but the SystemBrandingBlock uses an config factory injected via the create() method. Using an injected service is preferred I think.
  2. +  /**
    +   * @var ConfigFactoryInterface $config;
    +   */
    +  protected $configFactory;
    

    The fully-qualified interface name should be used for the @var declaration. See the API documentation standards for Indicating data types in documentation.

ravi.shankar’s picture

Assigned: Unassigned » ravi.shankar

Working on this.

ravi.shankar’s picture

StatusFileSize
new2.11 KB

Here I have added reroll of patch #6.

ravi.shankar’s picture

Assigned: ravi.shankar » Unassigned
StatusFileSize
new2.2 KB
new1.65 KB

Here I have addressed comment #7.

Still needs work for tests.

Kumar Kundan’s picture

Assigned: Unassigned » Kumar Kundan
Kumar Kundan’s picture

StatusFileSize
new3.04 KB
new696 bytes

Addressed test case.

Kumar Kundan’s picture

Assigned: Kumar Kundan » Unassigned
Status: Needs work » Needs review
darchuletajr’s picture

Reviewed and looks good to me.

mayurjadhav’s picture

Status: Needs review » Needs work

Patch looks good for me, I think we can have a patch for 8.9.x as well.

deepak goyal’s picture

StatusFileSize
new3.04 KB

Patch #12 cleanly apply on drupal version 8.8.

andrewmacpherson’s picture

Status: Needs work » Needs review

@Deepak Goyal - remember to explain what your patch does. How does it differ from patch #12?

deepak goyal’s picture

Version: 9.1.x-dev » 8.8.x-dev
StatusFileSize
new3.04 KB

@andrewmacpherson There is no difference with patch #12, But I applied same patch on version 8.8 and its working.

andrewmacpherson’s picture

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

Aha, thanks. A good way to check if a patch works for multiple branches is to use the "add/retest" links next to the patch ( I've just done next to #18, so we'll see result for 8.8 and 9.1). There's no need to repost the same patch.

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.

penyaskito’s picture

Status: Needs review » Needs work
+++ b/core/modules/node/tests/src/Functional/NodeSyndicateBlockTest.php
@@ -37,6 +37,11 @@ public function testSyndicateBlock() {
+    $syndicate_block_title = 'Subscribe to ' . $site_name;
+    $this->assertSession()->pageTextContains($syndicate_block_title);

Thanks for the patch!

This should be

$site_name = $this->config('system.site')->get('name');

We might be OK hardcoding this tho, and just doing

$this->assertSession()->pageTextContains('Subscribe to Drupal');

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.

vakulrai’s picture

Status: Needs work » Needs review
StatusFileSize
new2.96 KB
new2.96 KB

Rerolled patch for 9.3.x and updated tests as per #21.

Thanks.

marcoscano’s picture

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

Reviewed the code and it looks 👍 from my point of view. There is a nitpicky missing dot at the end of the inline comment in the test, but I'll hope committers will be willing to fix that on commit :)

marcoscano’s picture

Status: Reviewed & tested by the community » Needs work

Ops, I take it back.

  1. +++ b/core/modules/node/tests/src/Functional/NodeSyndicateBlockTest.php
    @@ -37,6 +37,10 @@ public function testSyndicateBlock() {
    +    // Verify syndicate block title
    

    Missing dot at the end of line.

  2. +++ b/core/modules/node/tests/src/Functional/NodeSyndicateBlockTest.php
    @@ -37,6 +37,10 @@ public function testSyndicateBlock() {
    +    $site_name = $this->config('system.site')->get('name');
    

    Now that we are hardcoding the expected string, this line is no longer needed.

dhirendra.mishra’s picture

Assigned: Unassigned » dhirendra.mishra

Let me work on this.

dhirendra.mishra’s picture

Assigned: dhirendra.mishra » Unassigned
StatusFileSize
new222.41 KB

Patch from #23 does not apply for me on 9.3.x

meenakshi_j’s picture

Status: Needs work » Needs review
StatusFileSize
new3.07 KB

Rerolled patch #23 and updated tests as per #25.

marcoscano’s picture

Status: Needs review » Reviewed & tested by the community

👍 Looks good!

  • catch committed 76b129c on 9.3.x
    Issue #3156244 by ravi.shankar, Deepak Goyal, Kumar Kundan, vakulrai,...
catch’s picture

Status: Reviewed & tested by the community » Fixed

Committed/pushed to 9.3.x, thanks!

Since this includes a constructor change, while it's allowable in 9.2.x, think we can probably wait for 9.3 with this one.

Status: Fixed » Closed (fixed)

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