NodeController::revisionOverview is uncacheable

Created on 11 August 2021, over 3 years ago
Updated 29 December 2023, 11 months ago

Problem/Motivation

NodeController calls $this->renderer->addCacheableDependency with an object that doesn't implement CacheableDependencyInterface, this results in an uncacheable page for DPC.

Steps to reproduce

Visit the node overview page
Notice that the page is uncacheable in dynamic page cache

Proposed resolution

username is a render array, use the correct API for merging cacheability metadata

Steps to test

1. On a fresh install of Drupal 9.3.x, apply the patch.
2. Create a node (can be published or unpublished).
3. Edit the node you created.
4. Open the web developer tools Inspect pane and select the Network tab.
4. View the node and click on its Revisions tab.
5. On the Network tab in your browser's Inspect tab, scroll up to the request for /revisions and select that row. In the adjacent tab, look under Respsonse Headers for the `x-drupal-dynamic-cache` row and note the value (should be MISS). Refresh the page and repeat, noting the new value (should be HIT).

Remaining tasks

1. Verify patch sets the x-drupal-dynamic-cache response header on node/%/revisions, i.e. node/1/revisions.
2. Add test coverage to verify that if the username is updated, the cache metadata that uses the username is also updated.

User interface changes

API changes

Data model changes

Release notes snippet

🐛 Bug report
Status

Needs work

Version

11.0 🔥

Component
Node system 

Last updated about 3 hours ago

No maintainer
Created by

🇦🇺Australia larowlan 🇦🇺🏝.au GMT+10

Live updates comments and jobs are added and updated live.
  • Needs manual testing

    The change/bugfix cannot be fully demonstrated by automated testing, and thus requires manual testing in a variety of environments.

Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • 🇵🇭Philippines abhaypai

    Came here from Bug smash initiative. I am still able to replicate this issue on D11 and tried initial level of debugging.

    Wondering why CacheableMetadata::createFromRenderArray($username)->addCacheableDependency($node) or CacheableMetadata::createFromRenderArray($username) are not working as expected. Checked type of argument that i am passing and also looked into multiple other ways of defining it, still x-drupal-dynamic-cache is not coming on response headers.

    Might need some more insights here from the community.

  • Status changed to Needs review 11 months ago
  • 🇵🇭Philippines abhaypai

    Might need some more insights here from the community, thats why moving it to Needs review status.

    Is it designed that way or needs fix ? note i am aware of related issue https://www.drupal.org/project/drupal/issues/3232018 and from my POV possibly we need to take some action on this issue, since it is affecting in many more pages with x-drupal-dynamic-cache: UNCACHEABLE in response headers.

  • Status changed to Postponed: needs info 11 months ago
  • Status changed to Needs work 11 months ago
  • 🇬🇧United Kingdom catch

    This doesn't need more info, the bug has been reproduced in #32 and also previously, it does need a conversion to an MR though at least.

  • 🇮🇳India Akhil Babu Chengannur

    By default, x-drupal-dynamic-cache header is present when revision oveview page is accessed and its value is 'UNCACHEABLE'.

    Now, If revision overview page is accessed after applying patch #17, x-drupal-dynamic-cache header wont be there. This is due tho the following condition in onResponse() method of DynamicPageCacheSubscriber.

        // Don't cache the response if the Dynamic Page Cache request & response
        // policies are not met.
        // @see onRequest()
        if ($this->requestPolicyResults[$request] === RequestPolicyInterface::DENY || $this->responsePolicy->check($response, $request) === ResponsePolicyInterface::DENY) {
          return;
        }
    
    

    $this->responsePolicy->check() calls several policy rules and Drupal\dynamic_page_cache\PageCache\ResponsePolicy\DenyAdminRoutes rule returns 'deny' for revison overview route as its an admin route. (_admin_route: true). So x-drupal-dynamic-cache header is omitted.

Production build 0.71.5 2024