Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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
Issue category | Bug |
---|---|
Issue priority | Normal because it's just a minor regression |
Prioritized changes | This is a bug fix. |
Comment | File | Size | Author |
---|---|---|---|
#57 | interdiff.txt | 1.85 KB | cafuego |
#57 | 2409417-57.patch | 13.23 KB | cafuego |
#46 | 2409417-46.patch | 13.14 KB | cafuego |
Comments
Comment #1
cafuego CreditAttribution: cafuego commentedDeleting 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.
Comment #2
cafuego CreditAttribution: cafuego commentedComment #3
cafuego CreditAttribution: cafuego commentedComment #4
cafuego CreditAttribution: cafuego commentedTurns 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.
Comment #5
dawehnerAh, can we also write some simple test coverage for it? This would be great
Comment #6
cafuego CreditAttribution: cafuego commentedComment #7
cafuego CreditAttribution: cafuego commentedAdded test coverage (I hope) in a new
testDisabledFeed()
function in DisplayFeedTest.php.The full patch should pass testing, the testonly-mustfail patch should fail on the final two tests only.
Comment #10
cafuego CreditAttribution: cafuego commentedLets try that again then.
Comment #13
cafuego CreditAttribution: cafuego commented... 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.
Comment #16
cafuego CreditAttribution: cafuego commentedOkay, 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?
Comment #19
cafuego CreditAttribution: cafuego commentedSpoke 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.
Comment #20
larowlanComment #22
jibran#20 was missing view.
Comment #23
larowlanjibran++
larowlan--
http://img2.wikia.nocookie.net/__cb20130617055401/thehungergames/images/...
Comment #24
jibranHere is test-only.patch.
Comment #26
jibranComment #27
mradcliffeManually 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?
Comment #28
jibranI 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.
Comment #29
dawehnerJust checked, for other stuff we check for the
isEnabled
flag already, so +1 from me.Comment #30
cafuego CreditAttribution: cafuego commentedI 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.
Comment #31
cafuego CreditAttribution: cafuego commentedAnd #2410539: Views schema prevents saving of view with disabled display through code is green, if someone would care to have a look :-)
Comment #34
cafuego CreditAttribution: cafuego commentedOkay, #2410539: Views schema prevents saving of view with disabled display through code is in, so this should now work without the extra schema change.
Comment #35
larowlanif green
Comment #36
alexpottIs 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?
Comment #37
jibran#36 does sound more convincing .
Comment #38
jibranLet's try #36
Comment #40
mradcliffeTest failures:
Drupal\Tests\views\Unit\ViewExecutableUnitTest
Looks like a unit test is expecting something to be enabled?
Drupal\views\Tests\PluginInstanceTest
Comment #43
jibranI'll have a look at the fail.
Comment #44
jibranThat was easy.
Comment #45
cafuego CreditAttribution: cafuego commentedNow 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?
Comment #46
cafuego CreditAttribution: cafuego commentedRefactored 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.
Comment #47
cafuego CreditAttribution: cafuego commentedD'oh. Forgot to change the feed test URL.
Comment #50
cafuego CreditAttribution: cafuego commented... and one more test fix (attachments is an array with multiple items now, use in_array()).
Comment #51
jibranWe can clean both the tests now.
We can use View::getView() here to get ViewExecutable. So we don't have to getExecutable() again and again.
We have CssSelector in drupal core now.
Comment #52
cafuego CreditAttribution: cafuego commentedDone.
That's a cool story, bro.
Comment #53
jibranWe have plenty of tests now. I think it is good to go. Thanks @cafuego for fixes and tests.
Comment #55
cafuego CreditAttribution: cafuego commentedDear bot, please assess.
Comment #57
cafuego CreditAttribution: cafuego commentedRefactored the test views, thanks Jibran.
Comment #58
jibranNice work @cafuego we have a unit tests and webtests for the change. I think it's good to go.
Comment #59
kattekrab CreditAttribution: kattekrab commentedI think this needs a Beta Evaluation.
Comment #60
jibranAdded BE to IS.
Comment #61
alexpottCommitted 37fec7e and pushed to 8.0.x. Thanks!
Thanks for adding the beta evaluation to the issue summary.
Fixed on commit - unused variables and English.
Comment #63
mradcliffeWoop. A decade old feature request is fixed. :-)
Comment #64
kattekrab CreditAttribution: kattekrab commentedwhoohooo - 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