Problem/Motivation
Originally raised this in #2563843-37: MapItem is broken for configurable fields but now splitting this off into its own issue.
FieldItemInterface::schema()
states:
/**
* ...
*
* @return array
* An empty array if there is no schema, or an associative array with the
* following key/value pairs:
* - columns: An array of Schema API column specifications, keyed by column
* name. The columns need to be a subset of the properties defined in
* propertyDefinitions().
* ...
*/
So since MapItem::schema()
returns a value
column, you would expect that there must be a value
property defined by MapItem::propertyDefinitions()
.
That is no longer the case, however, since #2229181: MapItem::propertyDefinitions() claims it has a static value property, which is wrong.
Besides clearly being a violation of the API, this breaks any widget that you try to write for MapItem
as widgets rely on the aforementioned relationship between schema columns and properties. Possibly other things are broken as well, but this is the one I encountered.
Proposed resolution
Roll back #2229181: MapItem::propertyDefinitions() claims it has a static value property, which is wrong.
Comment | File | Size | Author |
---|---|---|---|
#12 | 2887105-12.patch | 1.04 KB | Niklan |
Comments
Comment #2
BerdirHow do widgets rely on that? Anything on widgets can be overridden to do whatever you want? Widgets like Paragraphs and IEF have litte/nothing to do with the property/schema structure.
I agree that it does violate the documentation/description there, but it does reflect how it really behaves?
The only way to respect that documentation would be to change MapItem so that it contains a value map property, but that would obviously be a bigger API change.
Comment #4
joachim CreditAttribution: joachim as a volunteer commentedIt think it's this which causes a crash when installing an entity type using this field type (in my case, as a bundle field coming from a Commerce bundle plugin):
Comment #5
Wim LeersQuoting @tstoeckler at #2906600-7: FieldItemList::equals() doesn't work correctly for computed fields with custom storage:
Comment #7
Wim LeersConfirming #4. Detail at #2895532-124: @DataType=map cannot be normalized, affects @FieldType=link, @FieldType=map.
Comment #8
Wim LeersComment #12
NiklanThere is another problem with that definition removal. The base fields of "map" type can't be uninstalled.
Definition:
Hook update which tries to uninstall it:
This hook update fails with
. This is because
isRequired()
checks for!empty($this->definition['required'])
, but$this->definition
is an empty array, since there is no definition!I've managed to fix this by rollback the definition removal and run the update, which ended successfully. I think this issue needs more attention.
Attach the patch which solve my problem.
Comment #13
andypostComment #14
tstoecklerRe #12: Note that #2563843: MapItem is broken for configurable fields (which I just retitled and rebased) may help you as well. If not it would be great to know where
isRequired()
is being called would be awesome if you could provide some additional info in that case.Comment #15
Niklan@tstoeckler there is no nothing special. Simple content entity type + definition I've provided. It can't be uninstalled. It fails when check its property "is required", but there is no property.
I can't test your solution right now, since I bypass this error by temporary rollback definition removal. But this can be easily reproduced with just 1 base field installed on entity and trying to uninstall it then via hook_update_N().
Actually I copy-pasted all the code that reproduces bug as it is.
Comment #17
Sam152 CreditAttribution: Sam152 as a volunteer and at PreviousNext commentedHere is another impact this issue is having: #3145076: [backport] MapItem base fields cannot be uninstalled.
Edit: I can see this was mentioned in #12.
Comment #23
smustgrave CreditAttribution: smustgrave at Mobomo commentedThis issue is being reviewed by the kind folks in Slack, #needs-review-queue-initiative. We are working to keep the size of Needs Review queue [2700+ issues] to around 400 (1 month or less), following Review a patch or merge request as a guide.
Seems the last patch had some failures in D8 (triggered for D10)
Think we will need a test case also to show the issue.