Problem/Motivation
During __construct(), EntityDisplayBase ensures that all extra fields are correctly added as components.
However, it does so by directly manipulating internal variables, bypassing ::setComponent().
Any subclasses, such as the one added in #2922033: Use the Layout Builder for EntityViewDisplays, needs to be able to track the components as they are added.
Using the API will allow this.
See #2925657: EntityDisplayBase::init() should use ::setComponent() for fields and #2953656: No ability to control "extra fields" with Layout Builder
Proposed resolution
Use ::setComponent() correctly
Remaining tasks
N/A
User interface changes
N/A
API changes
N/A
Data model changes
N/A
Comment | File | Size | Author |
---|---|---|---|
#16 | 2956202-16.patch | 6.35 KB | tedbow |
#16 | interdiff-12-16.txt | 1.91 KB | tedbow |
#12 | 2956202-extrafield-12.patch | 6.29 KB | tim.plunkett |
#9 | interdiff-6-9.txt | 715 bytes | amateescu |
#9 | 2956202-9.patch | 6.19 KB | amateescu |
Comments
Comment #2
tim.plunkettSee core/profiles/standard/config/install/core.entity_view_display.node.article.default.yml line 55-59 for an example of a correctly configured extra field.
Hence the needed changes to the test coverage. They were asserting that incomplete config was returned!
Comment #3
tedbowThe changes look good.
Looking at
\Drupal\Core\Entity\EntityDisplayBase
now the only instance of$this->content[$name] =
is inside\Drupal\Core\Entity\EntityDisplayBase::setComponent()
And the only instance of
$this->hidden[$name] = TRUE;
is in\Drupal\Core\Entity\EntityDisplayBase::removeComponent()
RTBC, if patches test/fail as expected I think it is good.
Comment #5
xjmDiscussed with @tim.plunkett. He mentioned that this will result in changes to config exports as there are new entries added to entity displays for each field. So we need an upgrade path here to re-save the config so it happens on update rather than randomly adding diffs when something else is updated.
Per @tim.plunkett this is a blocker for #2953656: No ability to control "extra fields" with Layout Builder and the workaround without this fix is icky and possibly a performance issue. Layout Builder is beta experimental and so can have new BC functionality added in patch releases etc., so not having the issue affects how cleanly the fix can be backported to beta. However, since this is an issue with the entity system itself and upgrade paths that update config are preferably minor-only: I think we should start by getting this into 8.6.x, and then after commit we can decide whether it's better to backport this or not.
Thanks!
Comment #6
tim.plunkettWaited for ConfigEntityUpdater to go in, now this is much more straightforward.
Comment #8
tim.plunkettHmm, I can't make this change. Whoops.
(The other update was written for 8.3.0, so testing it on 8.4.0 doesn't work)
Splitting out the new test method to a new class. Interdiff looks destructive but it's okay :)
Comment #9
amateescu CreditAttribution: amateescu for Pfizer, Inc. commentedI was discussing this issue with Tim and I tried to use the existing test fixture locally and I can't seem to replicate the failures from #6. Let's try this out quickly, the interdiff is relative to the PASS patch from #6.
Comment #10
tedbowLooks great! Good tests!
Comment #12
tim.plunkettThanks @amateescu for steering me back to sanity there :)
Failed due to another post_update hook being added to system.
No interdiff.
Comment #13
tim.plunkettThis hard blocks #2953656: No ability to control "extra fields" with Layout Builder which is itself a major bug (albeit one in an experimental module)
Comment #14
tedbowduh!! Sorry about setting to RTBC in #10 when it actually needed a reroll. By the end of my review I had forgotten that had to reroll the patch for
system.post_update.php
Comment #15
larowlanSorry to drop this back to NW, but the comment needs work
could we split this array over multiple lines for readability? think it would fail phpcs as is
the english is off here
Comment #16
tedbowFixes for #15
Comment #17
tim.plunkettThanks @tedbow!
Comment #18
larowlanCrediting @xjm for the review that asked for an update path.
Not crediting my nit-review
Comment #19
larowlanCommitted as 223216c and pushed to 8.6.x.
Leaving at RTBC and will discuss with @xjm re back-port question raised in #5
Comment #23
tim.plunkettA little late for a backport to 8.5, I think we can be happy this got into 8.6 :)