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

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

plach’s picture

ChristianAdamski’s picture

Status: Closed (duplicate) » Active

This is really critical. I think whatever #2232427 might come up with in the long run, this should be addressed now.

ChristianAdamski’s picture

See also Core/FieldType/LinkItem:

// Unserialize the values.
    // @todo The storage controller should take care of this, see
    //   SqlContentEntityStorage::loadFieldItems, see
    //   https://www.drupal.org/node/2414835
    if (is_string($values['options'])) {
      $values['options'] = unserialize($values['options']);
    }
dawehner’s picture

@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 ...

ChristianAdamski’s picture

Well, 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.

catch’s picture

Priority: Critical » Major
Issue tags: +Contributed project soft blocker, +rc target triage

Yes 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.

tstoeckler’s picture

Status: Active » Needs review
Issue tags: +Needs tests
FileSize
3.14 KB

This 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.

Status: Needs review » Needs work

The last submitted patch, 7: 2414835-7.patch, failed testing.

dawehner’s picture

Also not sure what to do regarding BC here

What would be the BC problem introduced by this patch, once the patch actually works?

tstoeckler’s picture

So 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 a is_string, just like LinkItem, so ... ?

Berdir’s picture

We could always introduce a new marker interface for that but that would also make it harder to implement new field types in 8.1+.

xjm’s picture

Issue tags: -rc target triage

Version: 8.0.x-dev » 8.1.x-dev

Drupal 8.0.6 was released on April 6 and is the final bugfix release for the Drupal 8.0.x series. Drupal 8.0.x will not receive any further development aside from security fixes. Drupal 8.1.0-rc1 is now available and sites should prepare to update to 8.1.0.

Bug reports should be targeted against the 8.1.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.2.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

xjm’s picture

Issue summary: View changes

(Just removing the inaccurate (and now irrelevant) beta eval.)

catch’s picture

Status: Needs work » Closed (duplicate)

I 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.