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.
Views core stores CSS/JS and head contents in cache. But view can send some HTTP-headers, which are missing in cached output. For example, "Content-type" header from RSS feed is missing and output from cache has default HTML content type, which is wrong. Patch just adds HTTP headers to storage and reproduce them on retrieving from cache.
Probably its place is in Views core, not sure. Made from 6.x-2.2. It increases minimal PHP version to 5.0 because headers_list()
function was added in PHP 5.0. This shouldn't be a problem nowadays.
Comment | File | Size | Author |
---|---|---|---|
#29 | drupal-1312962-29.patch | 5.03 KB | dawehner |
#23 | drupal-1312962-23.patch | 4.79 KB | olli |
#23 | interdiff.txt | 1.06 KB | olli |
#21 | drupal-1312962-21.patch | 4.79 KB | dawehner |
#20 | drupal-1312962-20.patch | 3.63 KB | dawehner |
Comments
Comment #1
hefox CreditAttribution: hefox commentedYea, views seems better, nay?
Comment #2
Dmitriy.trt CreditAttribution: Dmitriy.trt commentedHere is updated patch based on Views 6.x-2.12. And for Views it is a bug, which also seems to affect 6.x-3.x and 7.x-3.x branches.
Comment #3
Dmitriy.trt CreditAttribution: Dmitriy.trt commentedOK, I understand that Views for Drupal 6 supports PHP 4 and the above patch won't be committed because of it.
Here is a port to Drupal 7 with the test to check that cached and non-cached RSS feed returns the same content type header.
Comment #4
dawehnerThanks for the patch. It is really great that you have added some tests as well.
What about adding a line which checks that the result is coming from the actual cache?
Comment #5
Dmitriy.trt CreditAttribution: Dmitriy.trt commentedAdded a few more assertions, including the one that we get the second result from cache.
Comment #6
dawehnerThanks for the tests again, they are simply great!
This is the patch i committed to 7.x-3.x, just had some small improvements.
Comment #7
Dmitriy.trt CreditAttribution: Dmitriy.trt commentedTo be honest, I don't familiar with changes coming with Drupal 8, but looks like the cache test case still have the same old location and format. What about a re-roll of the patch from 7.x? And the test will be converted to the new format later together with the other tests inside this test case if necessary.
Please, let me know if I'm really wrong about it.
Comment #9
Dmitriy.trt CreditAttribution: Dmitriy.trt commentedOK, please forget about my previous comment. I'll port it in my free time on this week.
Comment #10
dawehnerThis would be really helpful, because you know exactly the problem.
If you don't have time, someone will do it hopefully at some point in the future.
Comment #11
Dmitriy.trt CreditAttribution: Dmitriy.trt commentedSorry for a delay.
It should be safe to cache whole
Response
object if it has been changed on rendering, because it gets initialized inView::render()
, right before rendering process. Comparing it field-by-field would be a waste of time here.Comment #12
dawehnerThanks for porting the patch! Please don't worry about the delay as this is already more then i would expect people to do at this point of d8 development.
The response could also contain the output, see http://api.symfony.com/2.0/Symfony/Component/HttpFoundation/Response.html
and http://api.symfony.com/2.0/Symfony/Component/HttpFoundation/ResponseHead...
Maybe it would make sense to produce a diff of the components as well
Comment #13
Dmitriy.trt CreditAttribution: Dmitriy.trt commentedHere are possible improvements:
Response
class except for response text parsing or patching the core.pre_render()
function. But current implementations don't do it and there is apost_render()
function where they still can change the response. Probably it should be documented inviews_plugin_exposed_form::pre_render()
.What do you think? Which one should we implement?
About the response content, I think we should cache it too if it was set by the rendering code. It is possible to produce double caching of content because of not well written plugins, but it would be even worse if we drop response content on caching: if some component sets the response content, then it expects the content is still there after restoring from cache.
Comment #14
tim.plunkettComment #15
dawehnerAs all the files moved this patch have to be rerolled.
Comment #16
dawehnerIf something is setting the response output to early it's his own fault,
as long you can be sure views itself doesn't do that, i think that's okay.
Actually i don't see a reason why exposed_form::pre_render shouldn't be done a bit later.
Comment #17
dawehnerThis just contains a rerole
Comment #19
xjmComment #20
dawehnerLet's port this patch.
Comment #21
dawehnerMissing test file, sorry.
Comment #23
olli CreditAttribution: olli commentedAdded +s.
Comment #24
dawehnerOh good points, thank you!
Comment #26
olli CreditAttribution: olli commentedComment #28
olli CreditAttribution: olli commented#26: drupal-1312962-26.patch queued for re-testing.
Comment #29
dawehnerRerolled against HEAD, this looks really great, thank you for taking that over!
Comment #30
moshe weitzman CreditAttribution: moshe weitzman commentedSeems like we need drupal_render to start collecting headers in addition to css/js/library?
Comment #31
dawehner@moshe
It feels like this should be not done on the render api level but somehow on the SCOTCH level, no idea basically, but it feels wrong to set something which clearly is connected with the request/subrequest onto the rendering level.
Adding some random tags.
Comment #32
moshe weitzman CreditAttribution: moshe weitzman commentedFor now, those are the same thing. WHen you are building up your response, we need a way to collect headers/css/js/etc. Today, we often use render arrays for that. One day we won't.
Comment #33
dawehnerTo be honest it feels entirely wrong to store headers in render API, but I guess it's too late in the release cycle to wait for a proper implementation of scotch?
We could also get this hacky way in, and then convert to scotch, once they have figured it out.
Comment #34
dawehner#29: drupal-1312962-29.patch queued for re-testing.
Comment #47
darvanenThis was discusses as part of a group triage session in #bugsmash (slack channel).
Comment from @larowlan:
I manually tested on a fresh installation of 9.5.x with all defaults - i.e. caching turned on.
Went to the provided /rss.xml page and refreshed a few times, Content-Type header remains correct:
Marking as outdated. If you find reason to revive this issue please feel free to do so with clear steps to reproduce and an updated issue summary.