Problem/Motivation

As preparation and also discovered in #2824097: Deep serialization for content entities to make an exact snapshot of an entity object's structure based on its current state on wake-up of a serialized entity with references a strict comparison will fail as the id will be string and not an integer anymore.

Proposed resolution

EntityReferenceRevisionsItem::setValue should compare the entity id with "!=" instead with "!==".

Remaining tasks

Patch, Review & Commit.

User interface changes

None.

API changes

None.

Data model changes

None.

CommentFileSizeAuthor
#5 2850805-2.patch998 byteshchonov
#4 2850808-3.patch1.73 KBhchonov
#2 2850805-2.patch998 byteshchonov

Comments

hchonov created an issue. See original summary.

hchonov’s picture

Status: Active » Needs review
StatusFileSize
new998 bytes
hchonov’s picture

Issue summary: View changes
hchonov’s picture

StatusFileSize
new1.73 KB

Oups no need to duplicate the logic..

hchonov’s picture

StatusFileSize
new998 bytes

Ouups got the wrong patch uploaded ...

Re-uploading the previous again here...

miro_dietiker’s picture

Interesting discovery. Why is core unserialization not required to be type safe?
Is this nothing that should be addressed there?

I know we have similar type change problems via form state serialization/unserialize...

Does this affect a current use case too?

hchonov’s picture

Actually it is not the unserialization the problem it is just how I've came across the problem in the issue referenced in the IS.

I've opened a core ticket about the real problem - #2851149: Exceptions on setting entity reference field with integer target ID and entity object.

berdir’s picture

Yes, this is a standard problem, entity values are *not* type safe, like anything else coming from the database, and type safe checks don't work.

hchonov’s picture

#2851149: Exceptions on setting entity reference field with integer target ID and entity object has been committed, so I guess it is time to do the change here as well?

berdir’s picture

Status: Needs review » Reviewed & tested by the community

Yes, we've actually seen this fail on a paragraphs test. I guess this if fine to commit without explicit test coverage, but if we want, we could port the core tests, should be fairly easy.

  • miro_dietiker committed 6e335f6 on 8.x-1.x authored by hchonov
    Issue #2850805 by hchonov: EntityReferenceRevisionsItem::setValue should...
miro_dietiker’s picture

Status: Reviewed & tested by the community » Fixed

Committed, thx. :-)

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.