Page Cache causes different subrequests to return the same responses

Created on 19 April 2019, over 5 years ago
Updated 28 April 2023, over 1 year ago

Hello there
I'm trying to get results from views REST display.

Problem

I'v got 3 views (at least same problem with only 2 views), it's seems the results of the first views results is duplicate in all other results ....

How to reproduce

Create 2 views with rest display. It's views from a search API index but I think this change nothing.

here the blueprint I used

[
   {
      "requestId":"req-1",
      "action":"view",
      "uri":"/search/card-push-cold",
    "headers": {
        "Accept": "application/json"
      }
   },
   {
      "requestId":"req-2",
      "action":"view",
      "uri":"/search/card-content",
   "headers": {
        "Accept": "application/json"
      }
   }
]

Response body of req5 contains the response of req1,req2,req3,req4

🐛 Bug report
Status

Needs work

Version

3.0

Component

Miscellaneous

Created by

🇫🇷France musa.thomas France 🇫🇷

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Not all content is available!

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

  • 🇮🇳India rajeshreeputra Pune

    change_request_type-63049395-09.patch patch was failing, hence created new subrequests-3049395-change-request-type-47.patch patch, but not required as both seems identical hence removing.

  • Open in Jenkins → Open on Drupal.org →
    Core: 9.5.x + Environment: PHP 8.1 & MySQL 5.7
    last update over 1 year ago
    8 pass, 1 fail
  • Open in Jenkins → Open on Drupal.org →
    Core: 9.5.x + Environment: PHP 8.1 & MySQL 5.7
    last update over 1 year ago
    8 pass, 2 fail
  • Open in Jenkins → Open on Drupal.org →
    Core: 10.0.7 + Environment: PHP 8.1 & MySQL 5.7
    last update over 1 year ago
    8 pass, 1 fail
  • Open in Jenkins → Open on Drupal.org →
    Core: 9.5.x + Environment: PHP 8.1 & MySQL 5.7
    last update over 1 year ago
    8 pass, 1 fail
  • Open in Jenkins → Open on Drupal.org →
    Core: 10.1.x + Environment: PHP 8.1 & MySQL 5.7
    last update over 1 year ago
    8 pass, 2 fail
  • Open in Jenkins → Open on Drupal.org →
    Core: 9.5.x + Environment: PHP 8.1 & MySQL 5.7
    last update over 1 year ago
    8 pass, 1 fail
  • Open in Jenkins → Open on Drupal.org →
    Core: 10.1.x + Environment: PHP 8.1 & MySQL 8
    last update over 1 year ago
    8 pass, 1 fail
  • Open in Jenkins → Open on Drupal.org →
    Core: 10.0.7 + Environment: PHP 8.1 & MySQL 5.7
    last update over 1 year ago
    8 pass, 1 fail
  • 🇰🇬Kyrgyzstan sahaj

    I've upgraded to Drupal 10 and use the Merge request !9 patch, but I'm then getting the following error:

    Warning: Undefined array key "sub-content-type" in Drupal\subrequests\Normalizer\MultiresponseJsonNormalizer->normalize() (line 19 of modules/contrib/subrequests/src/Normalizer/MultiresponseJsonNormalizer.php).
    Drupal\subrequests\Normalizer\MultiresponseJsonNormalizer->normalize(Array, 'json', Array) (Line: 159)
    Symfony\Component\Serializer\Serializer->normalize(Array, 'json', Array) (Line: 138)
    Symfony\Component\Serializer\Serializer->serialize(Array, 'json', Array) (Line: 142)
    Drupal\rest\Plugin\views\style\Serializer->render() (Line: 438)
    Drupal\rest\Plugin\views\display\RestExport->Drupal\rest\Plugin\views\display\{closure}() (Line: 592)
    Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 439)
    Drupal\rest\Plugin\views\display\RestExport->render() (Line: 1548)
    Drupal\views\ViewExecutable->render() (Line: 429)
    Drupal\rest\Plugin\views\display\RestExport->execute() (Line: 1645)
    Drupal\views\ViewExecutable->executeDisplay('rest_export', Array) (Line: 81)
    Drupal\views\Element\View::preRenderViewElement(Array)
    call_user_func_array(Array, Array) (Line: 111)
    Drupal\Core\Render\Renderer->doTrustedCallback(Array, Array, 'Render #pre_render callbacks must be methods of a class that implements \Drupal\Core\Security\TrustedCallbackInterface or be an anonymous function. The callback was %s. See https://www.drupal.org/node/2966725', 'exception', 'Drupal\Core\Render\Element\RenderCallbackInterface') (Line: 797)
    Drupal\Core\Render\Renderer->doCallback('#pre_render', Array, Array) (Line: 386)
    Drupal\Core\Render\Renderer->doRender(Array, 1) (Line: 204)
    Drupal\Core\Render\Renderer->render(Array, 1) (Line: 148)
    Drupal\Core\Render\Renderer->Drupal\Core\Render\{closure}() (Line: 592)
    Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 149)
    Drupal\Core\Render\Renderer->renderRoot(Array) (Line: 407)
    Drupal\rest\Plugin\views\display\RestExport::buildResponse('slider_groups', 'rest_export', Array) (Line: 56)
    Drupal\views\Routing\ViewPageController->handle('slider_groups', 'rest_export', Object)
    call_user_func_array(Array, Array) (Line: 123)
    Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 592)
    Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 124)
    Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) (Line: 97)
    Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 181)
    Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 76)
    Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 44)
    Drupal\redirect_after_login\RedirectMiddleware->handle(Object, 1, 1) (Line: 68)
    Drupal\simple_oauth\HttpMiddleware\BasicAuthSwap->handle(Object, 1, 1) (Line: 58)
    Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 48)
    Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 106)
    Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 85)
    Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 53)
    Asm89\Stack\Cors->handle(Object, 1, 1) (Line: 48)
    Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 51)
    Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 51)
    Drupal\Core\StackMiddleware\StackedHttpKernel->handle(Object, 1, 1) (Line: 704)
    Drupal\Core\DrupalKernel->handle(Object) (Line: 19)
    Warning: Undefined array key "sub-content-type" in Drupal\subrequests\Normalizer\MultiresponseJsonNormalizer->normalize() (line 19 of modules/contrib/subrequests/src/Normalizer/MultiresponseJsonNormalizer.php).
    Drupal\subrequests\Normalizer\MultiresponseJsonNormalizer->normalize(Array, 'json', Array) (Line: 159)
    Symfony\Component\Serializer\Serializer->normalize(Array, 'json', Array) (Line: 138)
    Symfony\Component\Serializer\Serializer->serialize(Array, 'json', Array) (Line: 142)
    Drupal\rest\Plugin\views\style\Serializer->render() (Line: 438)
    Drupal\rest\Plugin\views\display\RestExport->Drupal\rest\Plugin\views\display\{closure}() (Line: 592)
    Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 439)
    Drupal\rest\Plugin\views\display\RestExport->render() (Line: 1548)
    Drupal\views\ViewExecutable->render() (Line: 429)
    Drupal\rest\Plugin\views\display\RestExport->execute() (Line: 1645)
    Drupal\views\ViewExecutable->executeDisplay('rest_export', Array) (Line: 81)
    Drupal\views\Element\View::preRenderViewElement(Array)
    call_user_func_array(Array, Array) (Line: 111)
    Drupal\Core\Render\Renderer->doTrustedCallback(Array, Array, 'Render #pre_render callbacks must be methods of a class that implements \Drupal\Core\Security\TrustedCallbackInterface or be an anonymous function. The callback was %s. See https://www.drupal.org/node/2966725', 'exception', 'Drupal\Core\Render\Element\RenderCallbackInterface') (Line: 797)
    Drupal\Core\Render\Renderer->doCallback('#pre_render', Array, Array) (Line: 386)
    Drupal\Core\Render\Renderer->doRender(Array, 1) (Line: 204)
    Drupal\Core\Render\Renderer->render(Array, 1) (Line: 148)
    Drupal\Core\Render\Renderer->Drupal\Core\Render\{closure}() (Line: 592)
    Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 149)
    Drupal\Core\Render\Renderer->renderRoot(Array) (Line: 407)
    Drupal\rest\Plugin\views\display\RestExport::buildResponse('slider_groups', 'rest_export', Array) (Line: 56)
    Drupal\views\Routing\ViewPageController->handle('slider_groups', 'rest_export', Object)
    call_user_func_array(Array, Array) (Line: 123)
    Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 592)
    Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 124)
    Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) (Line: 97)
    Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 181)
    Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 76)
    Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 44)
    Drupal\redirect_after_login\RedirectMiddleware->handle(Object, 1, 1) (Line: 68)
    Drupal\simple_oauth\HttpMiddleware\BasicAuthSwap->handle(Object, 1, 1) (Line: 58)
    Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 48)
    Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 106)
    Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 85)
    Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 53)
    Asm89\Stack\Cors->handle(Object, 1, 1) (Line: 48)
    Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 51)
    Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 51)
    Drupal\Core\StackMiddleware\StackedHttpKernel->handle(Object, 1, 1) (Line: 704)
    Drupal\Core\DrupalKernel->handle(Object) (Line: 19)
    

    And I'm really getting lost into this thread. What is the status of this issue and how to fix it?

  • e0ipso Can Picafort

    This issue is currently stalled.

  • Assigned to mglaman
  • 🇺🇸United States mglaman WI, USA

    Pinged @phenaproxima, he's not working on this. I'm going to take some time to go through the issue and MRs/patches.

  • Open in Jenkins → Open on Drupal.org →
    Core: 9.5.x + Environment: PHP 8.1 & MySQL 5.7
    last update about 1 year ago
    9 pass
  • Open in Jenkins → Open on Drupal.org →
    Core: 9.5.x + Environment: PHP 8.1 & MySQL 5.7
    last update about 1 year ago
    8 pass, 2 fail
  • 🇺🇸United States mglaman WI, USA

    Tests are passing, now. However I think the approach is wrong. We should be using SplObjectStorage to store cache IDs per-request object instead of the current approach. See \Drupal\Core\Path\CurrentPathStack for an example.

  • Open in Jenkins → Open on Drupal.org →
    Core: 9.5.x + Environment: PHP 8.1 & MySQL 5.7
    last update about 1 year ago
    9 pass
  • Open in Jenkins → Open on Drupal.org →
    Core: 9.5.x + Environment: PHP 8.1 & MySQL 5.7
    last update about 1 year ago
    9 pass
  • Issue was unassigned.
  • Status changed to Needs review about 1 year ago
  • 🇺🇸United States mglaman WI, USA

    Okay, the tests are fixed. I also updated the implementation to be something to be more resilient than relying on manipulating the request object.

  • Status changed to RTBC about 1 year ago
  • e0ipso Can Picafort

    This looks wonderful!

    Thanks for the work, and the patience everyone!!

  • Open in Jenkins → Open on Drupal.org →
    Core: 9.5.x + Environment: PHP 8.1 & MySQL 5.7
    last update about 1 year ago
    9 pass
  • Status changed to Fixed about 1 year ago
  • Automatically closed - issue fixed for 2 weeks with no activity.

  • 🇺🇦Ukraine t1mm1 Kiev

    Up!

    Updated patch from #47 for new release 3.0.12

  • 🇺🇸United States kevinquillen

    This issue is marked fixed, is the patch in 58 still needed?

  • 🇺🇸United States mglaman WI, USA

    This bug is fixed. The patch changes the type of request sent, which looks like a different issue.

Production build 0.71.5 2024