Looks like this:

comment:
    type: comment_default
    weight: 20

An empty settings key is mandatory, otherwise you get a recoverable fatal error.

Comments

benjy’s picture

Title: Comment widget and formatter display components are missing settings [d6] » Entity displays must have a settings array [d6]
Project: IMP » Drupal core
Version: » 8.x-dev
Component: Code » migration system
Status: Active » Needs review
StatusFileSize
new1.2 KB

As discussed on IRC the settings key is always required so we should just enforce this in ComponentEntityDisplayBase.

Status: Needs review » Needs work

The last submitted patch, 1: 2220559_1.patch, failed testing.

berdir’s picture

I'm wondering if we shouldn't move this to EntityBaseDisplay::setComponent() and ensure that settings is present there. Then we can also ensure it for code other than migrations.

benjy’s picture

Component: migration system » entity system
Status: Needs work » Needs review
StatusFileSize
new741 bytes

Yeah that would make more sense to me.

Status: Needs review » Needs work

The last submitted patch, 4: 2220559_4.patch, failed testing.

berdir’s picture

Title: Entity displays must have a settings array [d6] » Entity displays must have a settings array
Assigned: Unassigned » swentel

Interesting, I think those tests are wrong because those definitions would result in the mentioned errors when actually used.

Maybe @swentel can help us out here? :)

swentel’s picture

Assigned: swentel » Unassigned

So yeah, those tests should be changed, weird that we missed this.

berdir’s picture

Issue tags: +Entity Field API, +Novice

Cool, should make a pretty easy novice issue then to fix the assertion in those tests.

visabhishek’s picture

Status: Needs work » Needs review
StatusFileSize
new1.42 KB
new1.17 KB

I have updated the patch please review.

Status: Needs review » Needs work
swentel’s picture

@visabhishek you can just take the patch from #4 and then fix the assertions in EntityDisplayTest and EntityFormDisplayTest

swentel’s picture

Status: Needs work » Needs review
StatusFileSize
new3.87 KB
new3.15 KB
swentel’s picture

Status: Needs review » Needs work

Hmm, so come to think of it. It doesn't make sense to have a settings key for extra fields because they don't go through the formatter plugin manager.

swentel’s picture

Status: Needs work » Needs review
StatusFileSize
new795 bytes

So this should do it.

berdir’s picture

Status: Needs review » Reviewed & tested by the community

Great, discussed with @swentel, looks good.

webchick’s picture

Status: Reviewed & tested by the community » Needs work
Issue tags: +Needs tests

Can we get a test for this? (Not the specific regression itself, but whatever it is that triggers a recoverable fatal error when the fix missing.)

berdir’s picture

Hm, not sure in which that would make sense. But maybe we can extend the migrate tests so that they test this? They're not yet in core, though.

berdir’s picture

Ah, what we can do in one of those entity display tests is setting a component for an actual widget and then getComponent() and ensure it has settings set.

swentel’s picture

Hmm so, even with a widget with no settings, there is always a settings key. Especially since #2136197: Move field/instance/widget/formatter settings out of annotation / plugin definition, pluginSettingsBase has a defaultSettings() method which will always return an array anyway. (and possibly that was ok before that too) So not sure if we still need the protection ...

joshi.rohit100’s picture

Status: Needs work » Needs review
StatusFileSize
new764 bytes

last patch failed to apply so created this

Status: Needs review » Needs work

The last submitted patch, 20: 2220559-20.patch, failed testing.

amitgoyal’s picture

Status: Needs work » Needs review
StatusFileSize
new689 bytes

There are minor issues with the patch in #20 - "warning: 2 lines add whitespace errors.".

Please review revised patch as it applies cleanly.

Status: Needs review » Needs work

The last submitted patch, 22: 2220559-22.patch, failed testing.

l0ke’s picture

Status: Needs work » Needs review
StatusFileSize
new3.79 KB
new3.11 KB

Changing the assertions to make tests pass.

m1r1k’s picture

Issue tags: +#ams2014contest

benjifisher queued 24: 2220559-24.patch for re-testing.

Status: Needs review » Needs work

The last submitted patch, 24: 2220559-24.patch, failed testing.

hampercm’s picture

Issue tags: -

Taking a look at this for NERDSummit2014

hampercm’s picture

Status: Needs work » Needs review
StatusFileSize
new3.8 KB

Reroll of patch from #24.
Auto-merge

dawehner’s picture

+++ b/core/lib/Drupal/Core/Entity/EntityDisplayBase.php
@@ -302,6 +302,11 @@ public function setComponent($name, array $options = array()) {
+    if (!isset($options['settings'])) {
+      $options['settings'] = array();
+    }
+

You could just use $options += ['settings' => []] instead of the if()

Status: Needs review » Needs work

The last submitted patch, 29: 2220559-29.patch, failed testing.

henk’s picture

Assigned: Unassigned » henk

I am looking on it now.

henk’s picture

StatusFileSize
new3.63 KB

Reroll of patch from #29, core/modules/entity/src/Tests/ was moved to core/modules/field_ui/src/Tests/. I am not sure if "'settings' => array()" in each assert is needed if we have "if(!isset($options['settings']))" in setComponent method?

henk’s picture

Assigned: henk » Unassigned
Status: Needs work » Needs review

needs review

Status: Needs review » Needs work

The last submitted patch, 33: 2220559-33.patch, failed testing.

henk’s picture

Assigned: Unassigned » henk
Status: Needs work » Needs review
StatusFileSize
new3.35 KB

once again #33

Status: Needs review » Needs work

The last submitted patch, 36: 2220559-35.patch, failed testing.

henk’s picture

Status: Needs work » Needs review
StatusFileSize
new3.17 KB

Status: Needs review » Needs work

The last submitted patch, 38: 2220559-36.patch, failed testing.

henk’s picture

StatusFileSize
new4.03 KB

pass unittest

benjy’s picture

I think that initialising third_party_settings would also fix this Migrate issue? #2394615: User Profile entity form display need third_party_settings initialised

benjy’s picture

Status: Needs work » Needs review
StatusFileSize
new4.41 KB
new3.72 KB

I tested this and it does indeed fix the migrate issue. I think this is the best place for it, if there is no reason not to initialise third_party_settings as well then i'm going to close #2394615: User Profile entity form display need third_party_settings initialised in favour of this.

berdir’s picture

Status: Needs review » Reviewed & tested by the community
Issue tags: -Needs tests

Yes, this makes perfect sense to me, that's the issue I wanted to link to from the user profile migrate one. The API should ensure that those keys are set, especially given that we then rely on them.

henk’s picture

Assigned: henk » Unassigned
alexpott’s picture

Status: Reviewed & tested by the community » Fixed

This issue is a normal bug fix, and doesn't include any disruptive changes, so it is allowed per https://www.drupal.org/core/beta-changes. Committed 1867d61 and pushed to 8.0.x. Thanks!

  • alexpott committed 1867d61 on 8.0.x
    Issue #2220559 by benjy, swentel, lokeoke, visabhishek, hampercm, joshi....

Status: Fixed » Closed (fixed)

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