Closed (duplicate)
Project:
Drupal core
Version:
8.6.x-dev
Component:
link.module
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
8 May 2017 at 16:56 UTC
Updated:
20 Feb 2018 at 20:00 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
piggito commentedThe options field is defined as MapDataDefinition but the Map doesn't have any PropertyDefinition. Then, the ComplexDataNormalizer fails to loop over the properties in the Map and returns an empty array.
I'm uploading a patch which changes the options field from MapDataDefinition to DataDefinition::create('any') to overcome the issue.
Comment #3
piggito commentedComment #4
andypostBtw maybe kind of fix for normalization of
MapDataDefinitionrequired?Comment #5
andypostIt needs unit test to make sure
ComplexDataNormalizerworks fineComment #7
tacituseu commentedUnrelated failure, sorry, gave testbot a bit of a headache, might take a while to recover.
Comment #9
piggito commentedMy exact scenario was with menu_link_content so I'm adding a Kernel test for serialization of menu_link_content.
Comment #10
piggito commentedComment #11
piggito commentedComment #12
piggito commentedComment #14
andypostNow it needs aggregated patch #2+#9
Comment #15
piggito commentedThe menu link content test was just 1 scenario of LinkItem serialization issue so I created a new Kernel test to check serialization of LinkItems. I also include a new LinkItemNormalizer to solve the issue.
Comment #16
piggito commentedComment #18
piggito commentedAdding priority 20 to LinkItemNormalizer to make sure it is executed instead of ComplexDataNormalizer
Comment #20
wim leersHm… but:
So isn't the problem that maps aren't normalized correctly?
Comment #21
wim leersComment #22
piggito commentedI don't think it is a Map issue but the implementation of Map in LinkItem. The options attribute in LinkItem's definition is a Map but doesn't have its properties defined there and the ComplexDataNormalizer uses these properties to loop during normalization process.
Comment #23
piggito commentedI changed the approach and added options attributes in MapDefinition according to Url::fromUri
This way we can still use ComplexDataNormalizer
Comment #25
piggito commentedIt seems like the approach in #23 broke a lot of stuff so I came back to creating a LinkItem Normalizer that includes options property.
Comment #27
piggito commentedIt required a default normalizer and another one for hal module so I'm adding the patch.
Comment #28
larowlanLooks good, but will conflict with #2577923: MenuLinkContent entities pointing to nodes are not deployable: LinkItem should have a "target_uuid" computed property where we also add a link item normalizer
Comment #29
wim leersOnce #2871591: Allow ComplexData in TypedData to specify computed properties that should be exposed in normalization and other contexts is in, this will become much much simpler.
Comment #31
berdir@WimLeers: That issue is not the solution for every problem :)
options is *not* a computed property, so I'm not sure that issue will help. It is possible a more generic solution is possible, but not through computed properties but generic support for exporting map properties.
Comment #32
damiankloip commentedIf we do need a new normalizer here, it should be one on the data property level instead, i.e. a MapNormalizer? Another up side of that is that it would only need one normalizer in serialization module, not a field level implementation in both hal and serialization.
What you're doing here is basically what a MapNormalizer could/should/would do.
Tentatively moving back to open.
Wim, let me know if you still don't agree :)
Comment #33
lawxen commentedThis issue has been fixed on other issueMapData cannot be serialized by using a generic solution
which solved all data's normalization's problem that was defined as MapDataDefinition
1. core/LinkItem
2. commerce
3. BlockField
4. ...
Comment #34
andypost@liuxin the issue is not solved and related #2895532: @DataType=map cannot be normalized, affects @FieldType=link, @FieldType=map is not a half way in, I'd better marked related as duplicate
Comment #35
lawxen commentedHi @andypost,
I don't understand
It means "it's haven't been completely solved?" Or "it's not a shortcut“
Could you explain further?thanks
Comment #36
lawxen commented@andypost,Sorry for closing the issue hastily before,
The related #2895532: MapData cannot be serialized issue's resolution has divergence now
So, we should rethinking in the issue
Comment #38
berdirI agree with the duplicate. The other issue is close and among other things, has specific test coverage for the link field.