The Needs Review Queue Bot β tested this issue. It either no longer applies to Drupal core, or fails the Drupal core commit checks. Therefore, this issue status is now "Needs work".
Apart from a re-roll or rebase, this issue may need more work to address feedback in the issue or MR comments. To progress an issue, incorporate this feedback as part of the process of updating the issue. This helps other contributors to know what is outstanding.
Consult the Drupal Contributor Guide β to find step-by-step guides for working with issues.
- Merge request !4756Issue #327985: RSS Feed header reverts to text/html when cached β (Open) created by recrit
- last update
about 1 year ago 30,148 pass 13:04 4:16 Running- πΊπΈUnited States recrit
created a new issue branch "327985-11.x" for 11.x with patch #9 rolled on 11.x. Let's use this for development and then only post static patches based on the MR 4756.
- πΊπΈUnited States recrit
Attached is a static patch of MR 4756 at commit c952438a.
Work Pending: Add automated tests for RSS header content-type.
- Open on Drupal.org βEnvironment: PHP 8.2 & MySQL 8last update
about 1 year ago Not currently mergeable. - @recrit opened merge request.
- Open on Drupal.org βEnvironment: PHP 8.2 & MySQL 8last update
about 1 year ago Not currently mergeable. - @recrit opened merge request.
- Open on Drupal.org βEnvironment: PHP 8.2 & MySQL 8last update
about 1 year ago Not currently mergeable. - @recrit opened merge request.
- Merge request !4789Issue #327985 RSS Feed header reverts to text/html when cached β (Open) created by recrit
- last update
about 1 year ago 29,477 pass - πΊπΈUnited States recrit
Attached is the static patch for 10.1.x MR 4789.
- last update
about 1 year ago 30,362 pass, 2 fail - last update
about 1 year ago 29,617 pass, 4 fail - πΊπΈUnited States recrit
Added Step 0 to uninstall page cache modules that could be caching the HTTP response headers.
Added expected HTTP header.
Added new PHP interface. - πΊπΈUnited States recrit
Attached is a patch for 11.x that adds only the new test. This patch should fail which proves that a fix to core is needed.
- last update
about 1 year ago 30,358 pass, 2 fail - Open on Drupal.org βEnvironment: PHP 8.1 & MySQL 5.7last update
about 1 year ago Not currently mergeable. - last update
about 1 year ago 29,642 pass, 2 fail - last update
about 1 year ago 30,362 pass, 2 fail - last update
about 1 year ago 30,363 pass - last update
about 1 year ago 29,643 pass - Open on Drupal.org βEnvironment: PHP 8.1 & MySQL 5.7last update
about 1 year ago Not currently mergeable. - Open on Drupal.org βEnvironment: PHP 8.1 & MySQL 5.7last update
about 1 year ago Not currently mergeable. - πΊπΈUnited States recrit
FYI - "PHP 8.1 & MySQL 5.7 Not currently mergeable." is for some reason using the closed merge request 4788 without anyway to change it to the correct MR 4789. For that reason, I was unable to run the 10.1 test with PHP 8.1 & MySQL 5.7
- πΊπΈUnited States recrit
Summary up until now:
- 11.x: MR 4756
- Tests: PASS β at commit 8509a53c91
- Verify that D11.x fails without this fix: VERIFIED β - See "tests only" patch on #35 π RSS Feed header reverts to text/html when cached Fixed
- Static patch at 8509a53c91: Attached to this post - "3272985-D11.x-MR4756-8509a53c91--20230928.diff "
- 10.1.x: MR 4789
- Tests: PASS β at f56a2633c6
- Static patch at f56a2633c6: Attached to this post - "
3272985-D10.1.x-MR4789-f56a2633c6--20230928.diff"
- 11.x: MR 4756
- Status changed to Needs review
about 1 year ago 3:57pm 2 October 2023 - π³πΏNew Zealand quietone
In Slack, #gitlab, smustgrave asked for all MRs except 4756 and 4789 were closed. I have closed MR !2619, MR !2063 and MR !2042,
Cheers
- Status changed to Needs work
about 1 year ago 7:06pm 6 October 2023 - πΊπΈUnited States smustgrave
Thanks @quietone!
Tested on a fresh installed of 11.x with standard profile
I used the rss view that is installed
Confirmed the issue following the steps in the IS and that MR 4756 solved the issue.For the new trait believe we will need a change record
Good example would be https://www.drupal.org/node/3392235 β
- Status changed to Needs review
about 1 year ago 6:39pm 17 November 2023 - πΊπΈUnited States recrit
@smustgrave - Draft CR created at https://www.drupal.org/node/3402518 β
- Status changed to RTBC
about 1 year ago 2:24pm 18 November 2023 - last update
about 1 year ago 30,603 pass - last update
about 1 year ago 30,599 pass, 2 fail - Status changed to Needs work
about 1 year ago 4:16pm 20 November 2023 - π¬π§United Kingdom catch
I'm pretty sure this can be implemented using
#attached
, see comment on the MR. This would mean that views.theme.inc wouldn't need to do anything then either, and would save the API addition. - πΊπΈUnited States recrit
@catch this will not work in any preprocess function once it has been rendered cached. It will work the first time, but any request to the page after that will break. See comment #6 and #8 π RSS Feed header reverts to text/html when cached Fixed for more details.
- Status changed to Needs review
about 1 year ago 4:43pm 20 November 2023 - Status changed to Needs work
about 1 year ago 4:57pm 20 November 2023 - π¬π§United Kingdom catch
#6 and #8 don't mention using #attached, they just talk about the preprocess function, which is also not using #attached (hence why it doesn't work properly).
#attached does work with the cache system and I think it could be implemented in the style plugin directly rather than preprocess.
- πΊπΈUnited States recrit
@catch thanks .. When I first read your comment, I thought that you meant the preprocess function. I'll try using the #attached approach in
Drupal\views\Plugin\views\style\Opml::render()
andDrupal\views\Plugin\views\style\Rss::render()
to see if the test passes. - πΊπΈUnited States recrit
@catch Adding the
"['#attached']['http_header']"
to\Drupal\views\Plugin\views\style\Opml::render()
and\Drupal\views\Plugin\views\style\Rss::render()
does not work since the Feed display plugin usesreturns_response = TRUE
which get its own custom response processing. The views HTTPStatusCode area plugin get's added to page displays, so the displays build area gets processed in a way that the "#attached" is propagated to the response inDrupal\Core\Render\HtmlResponseAttachmentsProcessor
.Feed Display Response processing:
The Feed display plugin is the only core Views display plugin that uses thereturns_response = TRUE
. When the "returns_response" plugin property is set, the\Drupal\views\Routing\ViewPageController::handle()
uses the response as built by the display plugin with itsbuildResponse
. TheFeed::buildResponse()
renders the$build
array with aRendererInterface::renderRoot()
, adds only the cacheable metadata withCacheableMetadata::createFromRenderArray()
, and then returns the\Drupal\Core\Cache\CacheableResponse
instead of a build array. With that processing, the attachments do not get added to the response as expected.
The"['#attached']['http_header']"
approach could theoretically work if we added the code to process"['#attached']['http_header']"
inFeed::buildResponse()
similar to howDrupal\Core\Render\HtmlResponseAttachmentsProcessor
processes it.To test this approach, I created the "3272985-attached-approach-10.1.x-DO_NOT_USE-51.patch" for 10.1.x in order to show that it fails the new automated tests added in the MR. The same issue exists for 11.x too.
For reference
\Drupal\views\Routing\ViewPageController::handle()
:... $class = $route->getOption('_view_display_plugin_class'); if ($route->getOption('returns_response')) { /** @var \Drupal\views\Plugin\views\display\ResponseDisplayPluginInterface $class */ return $class::buildResponse($view_id, $display_id, $args); } else { /** @var \Drupal\views\Plugin\views\display\Page $class */ $build = $class::buildBasicRenderable($view_id, $display_id, $args, $route); Page::setPageRenderArray($build); views_add_contextual_links($build, 'page', $display_id, $build); return $build; }
- last update
about 1 year ago 29,684 pass, 2 fail - Status changed to Needs review
about 1 year ago 9:19pm 20 November 2023 - π¬π§United Kingdom catch
The "['#attached']['http_header']" approach could theoretically work if we added the code to process "['#attached']['http_header']" in Feed::buildResponse() similar to how Drupal\Core\Render\HtmlResponseAttachmentsProcessor processes it.
Thanks for trying it out. This approach sounds encouraging.
- Status changed to RTBC
about 1 year ago 3:45pm 21 November 2023 - πΊπΈUnited States smustgrave
Seems the feedback has been addressed?
- Status changed to Needs work
about 1 year ago 4:01pm 21 November 2023 - π¬π§United Kingdom catch
@smustgrave - no it hasn't, there haven't been any commits on the MR, only discussion.
- πΊπΈUnited States recrit
@catch I do not have any commits unless you are looking for the approach in #54 π RSS Feed header reverts to text/html when cached Fixed to be used instead of the current implementation.
- π¬π§United Kingdom catch
@recrit yes I think we should try the approach in #54 - i.e. make things work with the existing API rather than adding a new one.
- Status changed to Needs review
about 1 year ago 9:49pm 21 November 2023 - πΊπΈUnited States recrit
- π¬π§United Kingdom catch
That looks much better to me, and great to get rid of that logic from preprocess.
Last question I have is does this still work for the live preview situation?
- πΊπΈUnited States recrit
@catch Yes, it worked in my testing. Now, the HTTP headers are only added when the route is visited via the route callback
\Drupal\views\Routing\ViewPageController::handle()
instead of a theme function as it was before. - Status changed to RTBC
12 months ago 1:51am 26 November 2023 - πΊπΈUnited States smustgrave
Removed the Data model change from the IS as that no longer seems to be true.
Current CR is outdated and can be deleted.
Not sure if we need one for announcing headers being added but going to assume no.
Appears feedback has been addressed though and it's clear in the IS which MR to be committed.
1:31 58:39 Running- Status changed to Needs work
12 months ago 10:26am 26 November 2023 - π¬π§United Kingdom catch
Asked for an addition to the comment in the MR.
Agreed this doesn't need a change record, just a bugfix now.
- Status changed to Needs review
12 months ago 3:26pm 27 November 2023 - πΊπΈUnited States recrit
Updated both MRs with a comment to reference
\Drupal\Core\Render\HtmlResponseAttachmentsProcessor::setHeaders()
- Status changed to RTBC
12 months ago 3:55pm 27 November 2023 - Status changed to Needs work
12 months ago 10:10pm 27 November 2023 - π¬π§United Kingdom catch
Nearly went to commit this then spotted a couple more small issues, feel free to re-RTBC once these are resolved.
- Status changed to RTBC
12 months ago 10:58pm 27 November 2023 - Status changed to Fixed
12 months ago 11:05pm 27 November 2023 - π¬π§United Kingdom catch
Committed/pushed to 11.x and cherry-picked to 10.2.x, thanks!
- πΊπΈUnited States recrit
thanks! Attached is the final patch for 10.1.x for anyone still on that version.
Automatically closed - issue fixed for 2 weeks with no activity.