Problem/Motivation

Some users need to disable RSS feeds. Now that this is a view, it is possible to simply switch it off. However the RSS feed URL is still rendered in the front page headers.

Proposed resolution

Remove the rss URL from the front page headers when RSS feeds are disabled.

Before

After

Remaining tasks

Test coverage.

User interface changes

None

API changes

Beta phase evaluation

Reference: https://www.drupal.org/core/beta-changes
Issue category Bug
Issue priority Normal because it's just a minor regression
Prioritized changes This is a bug fix.
CommentFileSizeAuthor
#57 interdiff.txt1.85 KBcafuego
#57 2409417-57.patch13.23 KBcafuego
#55 interdiff.txt2.95 KBcafuego
#55 2409417-55.patch13.22 KBcafuego
#52 interdiff.txt4.49 KBcafuego
#52 2409417-52.patch13.26 KBcafuego
#50 interdiff.txt983 bytescafuego
#50 2409417-50.patch13.19 KBcafuego
#47 interdiff.txt908 bytescafuego
#47 2409417-47.patch13.14 KBcafuego
#46 interdiff.txt10.62 KBcafuego
#46 2409417-46.patch13.14 KBcafuego
#44 2409417-44.patch8.66 KBjibran
#44 interdiff.txt676 bytesjibran
#38 2409417-disabled-attachments-attach-things-37.patch8 KBjibran
#38 interdiff.txt2.79 KBjibran
#34 2409417-disabled-attachments-attach-things-34.patch7.7 KBcafuego
#27 feed-disabled-rss-link-removed.png173.33 KBmradcliffe
#27 feed-disabled.png61.47 KBmradcliffe
#27 drupal-installed-rss-link-in-markup.png180.32 KBmradcliffe
#27 drupal-installed-feed-enabled.png67.83 KBmradcliffe
#24 2409417-test-only.patch7.53 KBjibran
#22 2409417-22.patch8.2 KBjibran
#20 feeds-display.schema.patch3.42 KBlarowlan
#20 interdiff.txt516 byteslarowlan
#16 2409417-disabled-attachments-attach-things-16-testonly-mustfail.patch7.03 KBcafuego
#16 2409417-disabled-attachments-attach-things-16.patch7.7 KBcafuego
#13 2409417-disabled-attachments-attach-things-13-testonly-mustfail.patch1.91 KBcafuego
#13 2409417-disabled-attachments-attach-things-13.patch2.58 KBcafuego
#10 2409417-disabled-attachments-attach-things-10-testonly-mustfail.patch1.73 KBcafuego
#10 2409417-disabled-attachments-attach-things-10.patch2.44 KBcafuego
#7 2409417-disabled-attachments-attach-things-testonly-mustfail.patch1.75 KBcafuego
#7 2409417-disabled-attachments-attach-things-7.patch2.45 KBcafuego
#4 2409417-disabled-attachments-attach-things-4.patch724 bytescafuego
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

cafuego’s picture

Deleting the 'Feed' display from the front page view *does* remove the rss header, though.

I think it still shouldn't be displayed when the display is disabled only. At the very least the feed url is an information leak, even if it does return a 404 when accessed.

cafuego’s picture

Issue summary: View changes
cafuego’s picture

Component: base system » views.module
cafuego’s picture

Title: Disabling rss feed view does not remove rss header from front page » Disabling feed view display does not remove feed header from display it is attached to
Status: Active » Needs review
FileSize
724 bytes

Turns out this actually applies to all Feed views. The views display plugin attachTo() method is called, regardess of whether the display is enabled.

Attached patch checks whether a Feed display is enabled and does an early return if not. This stops rss headers being output on pages with disabled attached feed displays.

This probably needs a test.

dawehner’s picture

Issue tags: +VDC, +Needs tests

Ah, can we also write some simple test coverage for it? This would be great

cafuego’s picture

Issue summary: View changes
cafuego’s picture

Added test coverage (I hope) in a new testDisabledFeed() function in DisplayFeedTest.php.

  1. Enable the feed_display_test view
  2. Attach the feed to the page display
  3. Ensure the page display path returns status 200
  4. Ensure the rss header is output when accessing the page display
  5. Disable the feed display
  6. Ensure the rss header is not output when accessing the page display
  7. Ensure the feed display path returns status 404.

The full patch should pass testing, the testonly-mustfail patch should fail on the final two tests only.

The last submitted patch, 7: 2409417-disabled-attachments-attach-things-7.patch, failed testing.

Status: Needs review » Needs work
cafuego’s picture

Lets try that again then.

The last submitted patch, 10: 2409417-disabled-attachments-attach-things-10.patch, failed testing.

Status: Needs review » Needs work
cafuego’s picture

... and again. Weird unrelated test fails on local dev, so hopefully testbot will be more sensible. If not, I suspect there is an issue with the feeds test views; I was unable to make the feed_1 attachment display as attachment *at all* locally.

Status: Needs review » Needs work

The last submitted patch, 13: 2409417-disabled-attachments-attach-things-13.patch, failed testing.

cafuego’s picture

Okay, got further by adding a test view with attachment that in fact shows up locally, but I appear to not be able to edit that view to make the feed display be disabled without a schema validation error. Using the same code that ViewEditForm.php uses to set the enabled property to FALSE, but save() then errors out.

Not sure how to get around that. I am also not able to use $PluginTestsBase->container->get('entity.manager')->getStorage('view')->load('test_disabled_feed'); to load the view with pre-disabled display as exported from CMI.

Suggestions?

The last submitted patch, 16: 2409417-disabled-attachments-attach-things-16.patch, failed testing.

Status: Needs review » Needs work
cafuego’s picture

Spoke with larowlan. He reckons this is a schema problem, so this issue is blocked until #2410539: Views schema prevents saving of view with disabled display through code is resolved.

larowlan’s picture

Status: Needs work » Needs review
FileSize
516 bytes
3.42 KB

Status: Needs review » Needs work

The last submitted patch, 20: feeds-display.schema.patch, failed testing.

jibran’s picture

Status: Needs work » Needs review
FileSize
8.2 KB

#20 was missing view.

larowlan’s picture

jibran’s picture

Issue tags: -Needs tests
FileSize
7.53 KB

Here is test-only.patch.

Status: Needs review » Needs work

The last submitted patch, 24: 2409417-test-only.patch, failed testing.

jibran’s picture

Status: Needs work » Needs review
mradcliffe’s picture

Manually tested the patch and confirmed that the RSS link was removed when I disabled the frontpage feed display. Screenshots attached.

I think this is RTBC, but I'm not sure about the views schema issue. Is that no longer blocking this issue with patch #22?

jibran’s picture

Status: Needs review » Reviewed & tested by the community

I just merged two patches so I think I can RTBC the issue. It is ready. Thanks @cafuego, @larowlan for the fixes, thank you @mradcliffe for the screenshots and thank you @kattekrab for reporting the issue.

dawehner’s picture

Just checked, for other stuff we check for the isEnabled flag already, so +1 from me.

cafuego’s picture

Status: Reviewed & tested by the community » Postponed

I think we should fix (and test) the missing enabled property in the schema first for all displays, then get this patch in.... rather than haphazardly fix enabled for only this single display type and hope it remains working by wya of a sort of unrelated test.

cafuego’s picture

Status: Postponed » Needs work

And #2410539: Views schema prevents saving of view with disabled display through code is green, if someone would care to have a look :-)

jibran queued 24: 2409417-test-only.patch for re-testing.

The last submitted patch, 24: 2409417-test-only.patch, failed testing.

cafuego’s picture

Status: Needs work » Needs review
FileSize
7.7 KB

Okay, #2410539: Views schema prevents saving of view with disabled display through code is in, so this should now work without the extra schema change.

larowlan’s picture

Status: Needs review » Reviewed & tested by the community

if green

alexpott’s picture

Status: Reviewed & tested by the community » Needs review

Is this not a generic issue for all attachments - why is this not checked in Drupal\views\Plugin\views\display\Attachment::attachTo as well?

Should we be doing the enabled check here?

    // Find out which other displays attach to the current one.
    foreach ($this->display_handler->getAttachedDisplays() as $id) {
      $cloned_view = Views::executableFactory()->get($this->storage);
      $this->displayHandlers->get($id)->attachTo($cloned_view, $this->current_display, $this->element);
    }
jibran’s picture

Status: Needs review » Needs work

#36 does sound more convincing .

jibran’s picture

Status: Needs review » Needs work

The last submitted patch, 38: 2409417-disabled-attachments-attach-things-37.patch, failed testing.

mradcliffe’s picture

Test failures:

Drupal\Tests\views\Unit\ViewExecutableUnitTest

Looks like a unit test is expecting something to be enabled?

Drupal\views\Tests\PluginInstanceTest

Fatal error: Cannot use Drupal\Component\Utility\Xss as Xss because the name is already in use in /var/lib/drupaltestbot/sites/default/files/checkout/core/modules/views/src/Plugin/views/field/Field.php on line 11
FATAL Drupal\views\Tests\PluginInstanceTest: test runner returned a non-zero error code (255).

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, 38: 2409417-disabled-attachments-attach-things-37.patch, failed testing.

jibran’s picture

Assigned: Unassigned » jibran

I'll have a look at the fail.

jibran’s picture

Status: Needs work » Needs review
FileSize
676 bytes
8.66 KB

That was easy.

cafuego’s picture

Status: Needs review » Needs work

That was easy

Now for the tricky bit: more testing.

I hadn't initially done this for non-feed displays, as a disabled attachment display on an enabled page display resulted in ... problems.

So I guess we'll now need to modify the shipped test views to stick the attachment on a page, then check whether that keeps working. Same for a block, embed and entityreference display. Should we split that all out into a new test file?

cafuego’s picture

Status: Needs work » Needs review
FileSize
13.14 KB
10.62 KB

Refactored a little bit so the patch applies again. Added in a test view for disabled feed and attachments. Added disabled attachment test in DisplayAttachmentTest.php.

cafuego’s picture

FileSize
13.14 KB
908 bytes

D'oh. Forgot to change the feed test URL.

The last submitted patch, 46: 2409417-46.patch, failed testing.

Status: Needs review » Needs work

The last submitted patch, 47: 2409417-47.patch, failed testing.

cafuego’s picture

Status: Needs work » Needs review
FileSize
13.19 KB
983 bytes

... and one more test fix (attachments is an array with multiple items now, use in_array()).

jibran’s picture

Status: Needs review » Needs work

We can clean both the tests now.

  1. +++ b/core/modules/views/src/Tests/Plugin/DisplayAttachmentTest.php
    @@ -45,4 +55,54 @@ protected function testAttachment() {
    +    $view = $this->container->get('entity.manager')->getStorage('view')->load('test_attached_disabled');
    +    $view->getExecutable()->setDisplay('page_1');
    

    We can use View::getView() here to get ViewExecutable. So we don't have to getExecutable() again and again.

  2. +++ b/core/modules/views/src/Tests/Plugin/DisplayAttachmentTest.php
    @@ -45,4 +55,54 @@ protected function testAttachment() {
    +    $result = $this->xpath('//div[contains(@class, "view-content")]');
    ...
    +    $result = $this->xpath('//div[contains(@class, "attachment-before")]');
    ...
    +    $result = $this->xpath('//div[contains(@class, "attachment-after")]');
    ...
    +    $result = $this->xpath('//div[contains(@class, "view-content")]');
    ...
    +    $result = $this->xpath('//div[contains(@class, "attachment-before")]');
    ...
    +    $result = $this->xpath('//div[contains(@class, "view-content")]');
    ...
    +    $result = $this->xpath('//div[contains(@class, "attachment-after")]');
    

    We have CssSelector in drupal core now.

cafuego’s picture

Status: Needs work » Needs review
FileSize
13.26 KB
4.49 KB

We can use View::getView() here to get ViewExecutable. So we don't have to getExecutable() again and again.

Done.

We have CssSelector in drupal core now.

That's a cool story, bro.

jibran’s picture

Assigned: jibran » Unassigned
Status: Needs review » Reviewed & tested by the community

We have plenty of tests now. I think it is good to go. Thanks @cafuego for fixes and tests.

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 52: 2409417-52.patch, failed testing.

cafuego’s picture

Status: Needs work » Needs review
FileSize
13.22 KB
2.95 KB

Dear bot, please assess.

Status: Needs review » Needs work

The last submitted patch, 55: 2409417-55.patch, failed testing.

cafuego’s picture

Status: Needs work » Needs review
FileSize
13.23 KB
1.85 KB

Refactored the test views, thanks Jibran.

jibran’s picture

Status: Needs review » Reviewed & tested by the community

Nice work @cafuego we have a unit tests and webtests for the change. I think it's good to go.

kattekrab’s picture

I think this needs a Beta Evaluation.

jibran’s picture

Issue summary: View changes

Added BE to IS.

alexpott’s picture

Status: Reviewed & tested by the community » Fixed

Committed 37fec7e and pushed to 8.0.x. Thanks!

Thanks for adding the beta evaluation to the issue summary.

diff --git a/core/modules/views/src/Tests/Plugin/DisplayAttachmentTest.php b/core/modules/views/src/Tests/Plugin/DisplayAttachmentTest.php
index 4eb43e6..add8491 100644
--- a/core/modules/views/src/Tests/Plugin/DisplayAttachmentTest.php
+++ b/core/modules/views/src/Tests/Plugin/DisplayAttachmentTest.php
@@ -62,7 +62,7 @@ public function testAttachment() {
    */
   public function testDisabledAttachments() {
     $this->drupalCreateContentType(['type' => 'page']);
-    $node = $this->drupalCreateNode();
+    $this->drupalCreateNode();
 
     // Ensure that the feed_1 display is attached to the page_1 display.
     $view = Views::getView('test_attached_disabled');
diff --git a/core/modules/views/src/Tests/Plugin/DisplayFeedTest.php b/core/modules/views/src/Tests/Plugin/DisplayFeedTest.php
index f48385d..512541e 100644
--- a/core/modules/views/src/Tests/Plugin/DisplayFeedTest.php
+++ b/core/modules/views/src/Tests/Plugin/DisplayFeedTest.php
@@ -81,7 +81,7 @@ public function testFeedOutput() {
    */
   public function testDisabledFeed() {
     $this->drupalCreateContentType(['type' => 'page']);
-    $node = $this->drupalCreateNode();
+    $this->drupalCreateNode();
 
     // Ensure that the feed_1 display is attached to the page_1 display.
     $view = Views::getView('test_attached_disabled');
diff --git a/core/modules/views/src/ViewExecutable.php b/core/modules/views/src/ViewExecutable.php
index 1c43095..1ccd58e 100644
--- a/core/modules/views/src/ViewExecutable.php
+++ b/core/modules/views/src/ViewExecutable.php
@@ -1579,7 +1579,7 @@ public function attachDisplays() {
     // Find out which other displays attach to the current one.
     foreach ($this->display_handler->getAttachedDisplays() as $id) {
       $display_handler = $this->displayHandlers->get($id);
-      // Only attach enable attachments.
+      // Only attach enabled attachments.
       if ($display_handler->isEnabled()) {
         $cloned_view = Views::executableFactory()->get($this->storage);
         $display_handler->attachTo($cloned_view, $this->current_display, $this->element);

Fixed on commit - unused variables and English.

  • alexpott committed 37fec7e on 8.0.x
    Issue #2409417 by cafuego, jibran, larowlan: Disabling feed view display...
mradcliffe’s picture

Woop. A decade old feature request is fixed. :-)

kattekrab’s picture

whoohooo - thanks @alexpott and all who worked on this :)

Now just to get that final related issue through too.
#2409413: Remove fields that do nothing from the "RSS publishing" settings form

Status: Fixed » Closed (fixed)

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