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.
Problem/Motivation
If an entity type uses the field type 'map' as basefield, the serialized value in the database is not unserialized when an item is loaded.
$entity = Entity::load('muuuuuuuh');
$entity->save();
$entity_2 = Entity::load('muuuuuuuh');
$entity == $entity_2 // Should return TRUE, or at least theoretical
Proposed resolution
Fix it
Remaining tasks
User interface changes
API changes
Comment | File | Size | Author |
---|---|---|---|
#7 | 2414835-7.patch | 3.14 KB | tstoeckler |
Comments
Comment #1
plachI think this is a duplicate of #2232427: Allow field types to control how properties are mapped to and from storage,
Comment #2
ChristianAdamski CreditAttribution: ChristianAdamski as a volunteer commentedThis is really critical. I think whatever #2232427 might come up with in the long run, this should be addressed now.
Comment #3
ChristianAdamski CreditAttribution: ChristianAdamski as a volunteer commentedSee also Core/FieldType/LinkItem:
Comment #4
dawehner@dawehner Do you really think this is critical? This sounds for me more like a major issue in general, whether its a duplicate or not ...
Comment #5
ChristianAdamski CreditAttribution: ChristianAdamski as a volunteer commentedWell, somebody smarter then me decide this. It does come down to this:
I just used the gelocation module (see referenced by issue) and I could neither use views, nor store data because of this issue. However, a pretty simple setValue function in the fieldType definition of the geolocation field fixes this.
So: you kinda run unto unexpected fails. But: you have to use a contrib module, which is not aware of this issue. Core itself does take care of this on each occasion I found.
So my conclusion: reduce to major or even normal and move to 8.1, as changing this now would break the API.
Maybe update the docs somewhere to point to the issue, that serializing is handled automatically, but unserializing is not, for schema fields set to serialize.
Comment #6
catchYes I think this is an API annoyance for contrib modules, not a critical bug or contrib project blocker, so downgrading. Tagging for rc target triage since I'm not sure we can fix this in a minor release - would mean we have to avoid double-unserialize resulting from the change.
Comment #7
tstoecklerThis is completely untested, so more something to get the ball rolling that something RTBC-able. (Needs tests in any case.)
Also not sure what to do regarding BC here. Would be really sad to have to punt this to D9, but not really sure how we can do this without breaking stuff.
Comment #9
dawehnerWhat would be the BC problem introduced by this patch, once the patch actually works?
Comment #10
tstoecklerSo the problem is that there might be other field types like
LinkItem
that currently unserialize manually (because they have to). If we then fix this behavior, they might try to unserialize the already unserialized data.Although, thinking about this, I guess they should always be wrapping the
unserialize()
in ais_string
, just likeLinkItem
, so ... ?Comment #11
BerdirWe could always introduce a new marker interface for that but that would also make it harder to implement new field types in 8.1+.
Comment #12
xjmComment #14
xjm(Just removing the inaccurate (and now irrelevant) beta eval.)
Comment #15
catchI still think this is a duplicate of #2232427: Allow field types to control how properties are mapped to and from storage, also it's not at all clear which contrib modules it's an issue for at this point. Marking duplicate again.