Check if entity isNew() instead of the existence of the id() in _revision_log_default_get_original()

Created on 9 February 2024, 10 months ago

Problem/Motivation

_revision_log_default_get_original() checks if the entity has an id() to try to retrieve latest revision.

There are situation where the entity is new and might not have older revisions, like when migrating them, preserving IDs.

Would be more accurate to rely on isNew() method instead of the existence of the id value.

Steps to reproduce

Create moderated entities via migrate, preserving the ids in the original system as the original new IDs
Migration will throw PHP warning for every migrated entity:

[warning] array_flip(): Can only flip string and integer values, entry skipped ContentEntityStorageBase.php:667

Proposed resolution

Check $entity->isNew() instead if $entity->id() in _revision_log_default_get_original()

Remaining tasks

User interface changes

API changes

Data model changes

🐛 Bug report
Status

Needs review

Version

1.0

Component

Code

Created by

🇪🇸Spain plopesc Valladolid

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.71.5 2024