Problem/Motivation
In #2543340: Convert BlockViewBuilder to use #lazy_builder (but don't yet let context-aware blocks be placeholdered), it was discovered that these blocks carry around state, for no good reason. It used to be necessary due to limitations in the block rendering pipeline, but those limitations have since been fixed.
Rectifying this also makes the blocks significantly simpler.
And, in fact, due to this particular behavior, the Help block sometimes fail to bubble the url
cache context (because access is denied based on the URL, yet the access result does not reflect this!).
Proposed resolution
Fix them.
Remaining tasks
None.
User interface changes
None.
API changes
None.
Data model changes
None.
Beta phase evaluation
Issue category | Task because 1) sets the right example for contrib developers, 2) helps improve cacheability, 3) even fixes a cacheability bug |
---|---|
Issue priority | Normal because no big impact. |
Prioritized changes | The main goal of this issue is DX + cacheability. |
Disruption | Zero disruption. |
Comment | File | Size | Author |
---|---|---|---|
#18 | 2543554-block-18.patch | 5.41 KB | tim.plunkett |
#1 | 2543554-1.patch | 5.42 KB | Wim Leers |
|
Comments
Comment #1
Wim LeersComment #2
Wim LeersComment #3
dawehnerWait, don't we still have the problem of empty blocks not showing to be empty?
Comment #4
Wim LeersNo, that was fixed. See
if ($content !== NULL && !Element::isEmpty($content)) {
. Fixed in #1805054: Cache localized, access filtered, URL resolved, and rendered menu trees.Comment #5
Crell CreditAttribution: Crell at Palantir.net commentedDo we perhaps need a comment on the method in the interface that this method should NOT be used to vary visibility based on stateful information, eg, data that would be shared with build()? Seems like a wise thing to do, since we want to discourage module authors from doing... what we're making this block not do anymore. :-)
These changes are going to conflict with #1446932: Improve statistics performance by adding a swappable backend, which is largely rewriting this method.
Comment #6
Wim Leers#5:
i.e. blocks should not do stateful things in general. They should just… calculate things. But IMO that's out of scope for this issue. Created an issue for that: #2543984: Write BlockPluginInterface's docblock.
Comment #7
timmillwoodAs much as I hate conflicts I agree the statistics block should be an easy-to-resolve conflict, and as much as I would love #1446932: Improve statistics performance by adding a swappable backend into 8.0.x I'm not sure I can argue the case, so guess I need to accept conflicts.
Comment #8
Crell CreditAttribution: Crell at Palantir.net commentedSorry Wim, but I disagree. Whether or not we punt on documenting something seems to vary widely, depending primarily on whether or not jhodgdon is in the issue thread. :-) I'm going to channel her in this case and say that if this issue is fixing "these blocks are doing something unnecessarily stupid", then it should also be responsible for the documentation to ensure no one else does anything unnecessarily stupid.
Comment #9
Wim Leers#7: I'd be happy to reroll it for you even :) I'm probably more used to resolving conflicts, so happy to do it if that helps!
#8: Please, no. After >2 years, block plugins still have not been documented. Let's not put the responsibility to do that on an otherwise simple clean-up issue. These blocks are simply unnecessarily complex in their implementation. We should resolve that regardless of #2543340: Convert BlockViewBuilder to use #lazy_builder (but don't yet let context-aware blocks be placeholdered)'s needs, which just happened to resurface this.
Comment #10
timmillwood@wim - My patch pretty much just rewrites statistics_title_list function to work with the service also added in the patch, so should be pretty straightforward to merge.
If this was just the statistics patch I would RTBC, but I guess the block docs needs a fight.
Comment #11
Crell CreditAttribution: Crell at Palantir.net commentedI talked with Wim in IRC earlier today about this issue, and offered to just write the requisite docs myself. However, after staring at it for a while I realized I didn't know how to do it justice without referencing StatefulBlockPluginInterface as the correct way to handle edge cases... which of course doesn't exist yet and won't until #2543340: Convert BlockViewBuilder to use #lazy_builder (but don't yet let context-aware blocks be placeholdered). Sooo... I'm going to RTBC this and instead be annoying about documentation in that issue instead, as then we can do it properly (and it's partially done already by StatefulBlockPluginInterface itself).
Comment #14
Wim LeersGreen again.
Comment #15
tim.plunkett+1 as subsystem maintainer.
Comment #16
webchickI cannot possibly fathom how this is a quick fix. :D
Comment #17
alexpottNeeds a reroll.
Comment #18
tim.plunkettSimple reroll.
Conflicted with the cache context change of #2543332: Auto-placeholdering for #lazy_builder without bubbling
Comment #19
alexpottCommitting this as it improves cacheability. Committed d904faa and pushed to 8.0.x. Thanks!
Thanks you for adding the beta evaluation to the issue summary.