Problem/Motivation
This blocks #2450993: Rendered Cache Metadata created during the main controller request gets lost.
Proposed resolution
This is the part of the patch at #2450993-92: Rendered Cache Metadata created during the main controller request gets lost that can be split off, see #2450993-87: Rendered Cache Metadata created during the main controller request gets lost.
Remaining tasks
None.
User interface changes
None.
API changes
None.
Data model changes
None.
BETA EVAL:
Spin-off of #2450993: Rendered Cache Metadata created during the main controller request gets lost and hence a hard blocker for that one.
Comment | File | Size | Author |
---|---|---|---|
#6 | 2511472-6.patch | 169.08 KB | Wim Leers |
Comments
Comment #1
Wim LeersSee #2450993-93: Rendered Cache Metadata created during the main controller request gets lost.
Comment #2
Fabianx CreditAttribution: Fabianx for Acquia commentedRTBC, I reviewed all interdiffs already.
Comment #4
dawehnerLooks pretty great in general!
This change is really not obvious ...
This is a bit confusing, why can we no longer mock the interface? ... I think it is actually a step backward, as we seem to call out to the global container now, but haven't earlier
Comment #5
andypostfew things are filed as child issues in related
Comment #6
Wim LeersGAH! *One* stupid error in splitting up a 270 K patch :P Why couldn't that have been zero? :(
#4.1: unnecessary change, but I debugged the failures in the
SimpleTestTest
for a VERY long time, and turns out it is installing a module that it never uses/relies upon. To make further debugging easier, this helps reduce the search space of possible reasons.#4.2: because of
this. This doesn't do the rendering anymore, instead leaving the rendering to
\Drupal\Core\Ajax\CommandWithAttachedAssetsTrait
. The code you quoted is the mocking necessary for that trait.(The original would've worked as well, but this was resolved during a rebase conflict, at which time I did have a good reason to do this, but I don't remember.)
Comment #7
Fabianx CreditAttribution: Fabianx for Acquia commentedBack to RTBC, there are still some inconsistencies e.g. rendering vs. not rendering in Ajax responses, but that had been present before, such this is not making it worse, but better, because early rendering is moved to rely on the real renderRoot or renderPlain functions that should be used.
Comment #8
dawehnerI still don't get why we need to mock the actual instance of the class
Comment #9
Wim LeersIf you remove the mocked renderer service in the container, then this happens:
i.e.: the test calls
which calls
which calls
which calls
which calls
… hence we need to mock the renderer. Just like before. But instead of injecting a mocked renderer into
FormAjaxSubscriber
, we now do it on the container, because\Drupal\Core\Ajax\CommandWithAttachedAssetsTrait
uses the renderer, and that trait is used by AJAX commands that render HTML. I believe you helped land that at #2347469: Rendering forms in AjaxResponses does not attach assets automatically.Comment #10
Fabianx CreditAttribution: Fabianx for Acquia commentedThe question is why:
+ $renderer = $this->getMockBuilder('Drupal\Core\Render\Renderer')
and not
+ $renderer = $this->getMockBuilder('Drupal\Core\Render\RendererInterface')
It should not matter in difference ...
Comment #11
effulgentsia CreditAttribution: effulgentsia at Acquia commentedTherefore: Critical.
Comment #12
Wim Leers#10: Oh, nice nitpick find :) Should not matter indeed.
Comment #13
alexpottCommitted 68d4f0b and pushed to 8.0.x. Thanks!
Yep indeed this is better. Fixed on commit and ran tests with PHPUnit.
Comment #15
dawehnerYeah I'm not stupid ... the thing is, once you mock in a hard coded way, there is less guarantee that you can write alternative implementations one day.
Comment #16
andypostClosed as duplicate #2509606: book_node_view() breaks node render caching
but other 2 issues still needs review
Comment #17
Wim Leers@andypost: which 2 are that?
Comment #18
andypost@Wim Leers - Child issues in #2509534: [Meta] document or refactor calls to drupal_render()