Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
The options field of links is always serialized as empty array.
Comment | File | Size | Author |
---|---|---|---|
#27 | interdiff.txt | 4.67 KB | piggito |
#27 | normalization_of-2876686-27.patch | 6.02 KB | piggito |
Comments
Comment #2
piggito CreditAttribution: piggito as a volunteer and at Skilld 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 CreditAttribution: piggito as a volunteer and at Skilld commentedComment #4
andypostBtw maybe kind of fix for normalization of
MapDataDefinition
required?Comment #5
andypostIt needs unit test to make sure
ComplexDataNormalizer
works fineComment #7
tacituseu CreditAttribution: tacituseu commentedUnrelated failure, sorry, gave testbot a bit of a headache, might take a while to recover.
Comment #9
piggito CreditAttribution: piggito as a volunteer and at Skilld commentedMy exact scenario was with menu_link_content so I'm adding a Kernel test for serialization of menu_link_content.
Comment #10
piggito CreditAttribution: piggito as a volunteer and at Skilld commentedComment #11
piggito CreditAttribution: piggito as a volunteer and at Skilld commentedComment #12
piggito CreditAttribution: piggito as a volunteer and at Skilld commentedComment #14
andypostNow it needs aggregated patch #2+#9
Comment #15
piggito CreditAttribution: piggito as a volunteer and at Skilld 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 CreditAttribution: piggito as a volunteer and at Skilld commentedComment #18
piggito CreditAttribution: piggito as a volunteer and at Skilld 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 CreditAttribution: piggito as a volunteer and at Skilld 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 CreditAttribution: piggito as a volunteer and at Skilld commentedI changed the approach and added options attributes in MapDefinition according to Url::fromUri
This way we can still use ComplexDataNormalizer
Comment #25
piggito CreditAttribution: piggito as a volunteer and at Skilld 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 CreditAttribution: piggito as a volunteer and at Skilld 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 CreditAttribution: damiankloip at Acquia 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 CreditAttribution: lawxen at Sparkpad 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 CreditAttribution: lawxen at Sparkpad 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 CreditAttribution: lawxen at Sparkpad 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.