While writing a PHPUnit functional test that installs a full install profile (Lightning, in this case), I encountered this error:
Drupal\Core\Config\Schema\SchemaIncompleteException: Schema errors for core.entity_form_display.scheduled_update.multiple_node_embargo.default with the following errors: core.entity_form_display.scheduled_update.multiple_node_embargo.default:content.entity_ids.settings.size variable type is string but applied schema class is Drupal\Core\TypedData\Plugin\DataType\IntegerData
I traced this a bit and discovered that it was due to this error in EntityReferenceAutocompleteWidget:
public static function defaultSettings() {
return [
'match_operator' => 'CONTAINS',
'size' => '60',
'placeholder' => '',
] + parent::defaultSettings();
}
Config schema says size should be an integer. The widget is defining it as a string for some reason. That's no good :) As far as I can tell, there is no reason it should be a string, and this will certainly trip up other config-aware tests. So it should be fixed in core.
Comment | File | Size | Author |
---|---|---|---|
#33 | 2885441-33-7.x.patch | 2.24 KB | acbramley |
#28 | 2885441-28.patch | 2.36 KB | acbramley |
#28 | interdiff-2885441-23-28.txt | 1.91 KB | acbramley |
#9 | 2885441-9.patch | 3.22 KB | phenaproxima |
#7 | interdiff-2885441-2-7.txt | 1.31 KB | phenaproxima |
Comments
Comment #2
phenaproximaHere's a patch; not sure if it needs tests. If it does, I'm not sure what kind of tests it needs. A little guidance on that front would be appreciated!
Comment #3
phenaproximaD'oh!
Comment #4
jibranNice catch! Let's write some tests.
Comment #5
phenaproximaHappy to, but I'm not sure how exactly to go about testing this. Any guidance would be heavily appreciated :)
Comment #7
phenaproximaOkay, here we go. A bit awkward, to be sure, but EntityReferenceAutocompleteWidget does not seem to have a dedicated unit test :)
Comment #8
jibranThe test looks good. I think we need to update the existing formatters settings as well so we need an upgrade path and upgrade path tests.
Comment #9
phenaproximaHere's a first crack at the update path. No tests yet, though.
Comment #10
amateescu CreditAttribution: amateescu for Pfizer, Inc. commentedThe upgrade function looks great to me, just one comment so far:
Field types, widgets and formatters are still in the "field" realm of the Entity Field API, and we usually put field-related updates in field.install.
So this should be moved there as
field_update_8401()
;)Comment #11
jibranWe are not changing the config schema structure we are just updating existing value so we should use post-update function for this.
Now that schema is correct just load the form display entity using entity api and save it in post-update hook.
Comment #12
phenaproximaWrote an update path test and addressed @amateescu's feedback in #10, then @jibran's feedback in #11. :)
Comment #13
jibranThanks, @phenaproxima this was quick. :D
If the schema type is correct then why do we need typecasting here?
We are only checking the default settings. What about the settings? Is this correct for save settings?
Comment #14
phenaproximaAdding a fail patch at @jibran's request.
Comment #16
phenaproximaFail patch failed? Good, I say.
Comment #17
jibranAs confirmed by @phenaproxima in IRC that the issue is only with default size value, not with the saved size value. This means we don't need an upgrade path we only need a test to verify that saved size value is an integer
Comment #21
dwkitchen CreditAttribution: dwkitchen commentedNo longer applies on 8.8.x
Comment #22
dwkitchen CreditAttribution: dwkitchen commentedRe-roll to 8.8.x
Comment #23
acbramley CreditAttribution: acbramley at PreviousNext commentedRemoved the upgrade path, update test, and update fixture as per #17
Would be great to get this in as it's blocking #2863188: Hardcoded result size limit in the entity reference autocomplete widget.
Comment #25
hchonovThis should be:
Comment #26
hchonovThen it would be better to check the type before and after saving the form display.
Comment #27
hchonovActually I think that it is enough to only load
EntityReferenceAutocompleteWidget
and all of its subclasses and simply call theirdefaultSettings()
method and asserts, that the size is an integer - of course only if'size'
is present in the returned settings.Even better - let's do this for all widgets and formatters and check their default values against the specified type in their schema. Having such a general test will show if we have more similar inconsistencies and also will prevent us from introducing new inconsistencies with new code.
Comment #28
acbramley CreditAttribution: acbramley at PreviousNext commentedWent for #26 over #27 as that sounds out of scope of this issue and a good candidate for a follow up.
Comment #29
hchonovThat is fair. I think that it looks good now. Thank you.
Comment #30
larowlanComment #32
larowlanCommitted 49fae2a and pushed to 8.8.x. Thanks!
Needs re-roll for 8.7.x
Comment #33
acbramley CreditAttribution: acbramley at PreviousNext commentedRe-rolled for 8.7.x
Comment #34
jibranThanks!
Comment #36
catchCommitted/pushed the 8.7.x backport, thanks!
Comment #38
bogdog400 CreditAttribution: bogdog400 commentedI'm still getting this error when running "composer upgrade" because composer tries to just install the patch.
Comment #39
dwkitchen CreditAttribution: dwkitchen at CommitteeHQ commented@bogdog400, you no longer need to apply the patch it has been committed. Remove it from your composer.json file.