Render the inbox table in a placeholder, so the inbox page can be cached

Closes https://www.drupal.org/project/orchestra/issues/3628886

The inbox page was never cached: its task table carries the user context, which reached the response, so the Dynamic Page Cache answered UNCACHEABLE (poor cacheability) on every visit. The table had no #cache keys either, so nothing cached it.

  • InboxController::buildInbox() now returns an always-placeholdered #lazy_builder with #cache keys. The page shell is cached once per permission set; the table is render-cached per user, tenant and URL, with the tags and max-age it already declared.
  • The placeholder is a table child of the page array, not the array itself: HtmlRenderer adds #cache_properties to main content that has #cache keys, and an element with a #lazy_builder may carry no other property (an assertion, so a 500 wherever zend.assertions is on).
  • The lazy builder is InboxController::buildTable() (trusted callback), instantiated by core's callable resolver through create(), so no new service.
  • The table reads the return URI from the request stack instead of taking an argument: the Dynamic Page Cache keys the shell by route, not query string, so an argument would be replayed from the cached shell to another page of the pager. It adds the url context for the same reason.
  • TaskInboxTest::testInboxPageIsCachedPerOperator() (dynamic_page_cache enabled): MISS then HIT on the inbox; the Claim link returns to the current request's query string, not the cached one's; a second operator with the same role, at the same URL the first one's table is cached under, gets a HIT without the task the first one claimed (dropping the user context from the table fails it). The test-only changes job confirms it fails without the fix: the first visit answers UNCACHEABLE (poor cacheability) where MISS is expected.
  • Kernel tests (WorkItemPresentationTest, EmbeddedTaskTest, InteractionTaskTest) call buildTable(); testInboxLinksCarryReturn pushes its request, with a query string, onto the stack.
  • WorkItemPresentationTest::testInboxPageRenders() sends a real request through http_kernel, so the page renderer runs; with the placeholder as the page array itself it fails on that assertion.
Edited by Frank Mably

Merge request reports

Loading
Loading