Problem/Motivation

Using Classy as an example theme, when I load a page with a dropbutton the JS and CSS is not loaded:

When I rebuild the cache, the dropbuttons appear on the subsequent page load:

Proposed resolution

Investigate

Remaining tasks

Investigate

User interface changes

Fixed dropbutton

API changes

None

Data model changes

None

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

willzyx’s picture

This happens even using bartik and I think that happens with any theme..
The problems seems to be in views + render cache; if you disable the render cache (using cache.backend.null) or you disable the views module, dropbutton.js is attached to the page and dropbuttons are displayed properly. Not totally sure but the problem seems to be how views renders fields in FieldPluginBase::advancedRender()

jcnventura’s picture

On my tests, this only happenned on /admin/content

willzyx’s picture

also /admin/people is affected. I think that every page generated by views in which there are dropbuttons is affected

LewisNyman’s picture

hmm yeah the dropbuttons on the node creation page are still rendering so this could be a views issue.

willzyx’s picture

Component: system.module » views.module

moving to views.module component

olli’s picture

Issue tags: +VDC, +D8 cacheability
dawehner’s picture

We seriously need a test for that, but maybe more important, get a more sane architecture in place for things which are renderer maybe or maybe not inside a render context.
You should be able to write APIs which can be used outside of a render context, otherwise all your render related APIs will be bound in its usage to render API, not just internally,
and this is IMHO horrible on the longrun for maintainability.

Wim Leers’s picture

This regression was introduced by #2511472: Refactor all usages of drupal_render()/Renderer::render() that break #2450993. That, in turn, was a spin-off/child issue of #2450993, and at #2450993-33: Rendered Cache Metadata created during the main controller request gets lost, the change to StylePluginBase that causes this problem was introduced.

The root cause:

  • Views' render pipeline is string-based (not render array-based), because of legacy reasons and because it needs to be able to support any output format, not just HTML. This means that StylePluginBase needs to be string-based.
  • This means that for attachments to bubble, StylePluginBase needs to use render(), and not renderPlain(). This used to be the case until #2511472: Refactor all usages of drupal_render()/Renderer::render() that break #2450993. (Clearly we're missing some test coverage there.)
  • So, the solution seems simple: change renderPlain() back to render(). This will bubble onto the main rendering context.
  • But! Non-HTML views may very well not be using the regular render pipeline. And then calling render() will cause exceptions.
  • Fortunately, solving #2351015: URL generation does not bubble cache contexts required us to add a RendererInterface::hasRenderContext() method. Which we can now handily exploit to use either render() or renderPlain().

Yes, this is horrendous. But given the facts (Views' render pipeline was not updated in Drupal 8 to be render array-based, nor do render arrays support any format other than HTML, we have hasRenderContext() because of deficiencies in the URL generation APIs), this seems like a fair compromise. Views is likely the only piece of code that needs to ever do this.

Wim Leers’s picture

You should be able to write APIs which can be used outside of a render context, otherwise all your render related APIs will be bound in its usage to render API, not just internally,
and this is IMHO horrible on the longrun for maintainability.

Agreed that these are important goals. We won't achieve them in 8.0.0. We must achieve them in 9.0.0. We should starting to achieve them in 8.x.0.

gints.erglis’s picture

Status: Needs review » Reviewed & tested by the community

#8 patch can be applied and fix issue

jcnventura’s picture

Status: Reviewed & tested by the community » Needs work

Conflict between RTBC and 'Needs tests'

StryKaizer’s picture

Assigned: Unassigned » StryKaizer

Working on a test

StryKaizer’s picture

Test only + test & patch added

The last submitted patch, 13: TEST-ONLY-SHOULD-FAIL_dropbutton_library_is-2544162-13.patch, failed testing.

The last submitted patch, 13: TEST-ONLY-SHOULD-FAIL_dropbutton_library_is-2544162-13.patch, failed testing.

jcnventura’s picture

Status: Needs review » Reviewed & tested by the community

Nice test! I've also reviewed the patch, so I'm restoring it to RTBC.

Let's get this in asap. We shouldn't ship RC1 without this.

lauriii’s picture

Just added some docs because otherwise no one will remember why this test is being done.

alexpott’s picture

Status: Reviewed & tested by the community » Fixed

Committed decb9b1 and pushed to 8.0.x. Thanks!

  • alexpott committed decb9b1 on 8.0.x
    Issue #2544162 by StryKaizer, lauriii, Wim Leers, LewisNyman, jcnventura...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.